我在我的计算机上安装了 import android.os.AsyncTask;
import android.os.Bundle;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.util.ArrayList;
import java.util.Properties;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import android.app.Activity;
import android.util.Log;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends Activity {
private String user = "root"; //username
private String pass = "password"; //password
private String host = "hostname"; //hostname
private int portNum = 22; //replace port number
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new AsyncTask<Integer, Void, Void>() {
@Override
protected Void doInBackground(Integer... params) {
try {
executeRemoteCommand(user, pass, host, portNum);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}.execute(1);
}
public String executeRemoteCommand(String username, String password, String hostname, int port)
throws Exception {
//declare list and array
final ListView list = (ListView)findViewById(R.id.choose_sound_listView);
ArrayList<String> soundNames = new ArrayList<String>();
JSch jsch = new JSch();
Session session = jsch.getSession(username, hostname, port);
session.setPassword(password);
// Avoid asking for key confirmation
Properties prop = new Properties();
prop.put("StrictHostKeyChecking", "no");
session.setConfig(prop);
session.connect();
Channel channel = session.openChannel("shell");
channel.connect();
DataInputStream dataIn = new DataInputStream(channel.getInputStream());
DataOutputStream dataOut = new DataOutputStream(channel.getOutputStream());
// send ls command to the server
dataOut.writeBytes("ls\r\n");
dataOut.flush();
// and print the response
String line = dataIn.readLine();
String out = line + "\n";
// loop to add log string values to array
for (int i = 0; i < 10; i++) {
line = dataIn.readLine();
out += line + "\n";
Log.i("SSH", ": " + line);
//add to array
soundNames.add(line);
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1, android.R.id.text1
, soundNames);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
// Show Alert
Toast.makeText(getApplicationContext(),
"Alert", Toast.LENGTH_LONG)
.show();
}
});
dataIn.close();
dataOut.close();
channel.disconnect();
session.disconnect();
return out;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
}
。
创建新项目时,我没有Visual Studio 2015 RC SDK
模板。这是Visual Studio Package
正如您所见,Visual Studio 2015 RC
没有模板。
这是我Visual Studio Package
的屏幕截图:
问题
如何在Visual Studio 2013
中制定VSPackages
?
注意
我已经安装了Visual Studio 2015 RC
。
答案 0 :(得分:2)
在VS 2015中,您从VSIX项目开始,然后添加项目,例如VSPackage - 请参阅http://blogs.msdn.com/b/visualstudio/archive/2015/05/29/extending-visual-studio-2015.aspx