当前位置: 动力学知识库 > 问答 > 编程问答 >

android - how to start connectbot from my own activity via intent

问题描述:

I've got problem for my application. I want to start connectbot from my application via intent, if my activity start i want to connectbot start too. How to intent connectbot application from my activity, please for answer my question. thanks...

网友答案:

The AndroidManifest of ConnectBot has the following intent-filter:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:scheme="ssh" />
  <data android:scheme="telnet" />
  <data android:scheme="local" />
  <!-- format:  ssh://[email protected]:port/#nickname  -->
  <!-- format:  telnet://host:port/#nickname  -->
  <!-- format:  local://  -->
</intent-filter>

This means you can throw an Intent with the following action to start ConnectBot and open the ConsoleActivity. ConsoleActivity does not do anything with the Uri, so you could use anything starting with "ssh://":

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("ssh://[email protected]:port/#nickname")));

ConnectBot also responds to ACTION_PICK which opens the list of configured connections. ACTION_PICK actually parses the given uri and opens nickname but only if user, host and port are also right.

分享给朋友:
您可能感兴趣的文章:
随机阅读: