1 : A.apk activity 访问B.apk 的activity
在B.apk中AndroidManifest.xml中定义
<activity
android:name=".activity.MessageCompose"
android:label="@string/app_name"
android:enabled="false" >
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.SEND " />
<data android:mimeType="*/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
A.apk 访问 B.apk 的MessageCompose.activity:
Intent send = new Intent(Intent.ACTION_SEND );
send.setType("text/plain");
send.putExtra(Intent.EXTRA_TEXT, url);
send.putExtra(Intent.EXTRA_SUBJECT, title);
send.putExtra(Browser.EXTRA_SHARE_FAVICON, favicon);
send.putExtra(Browser.EXTRA_SHARE_SCREENSHOT, screenshot);
try {
c.startActivity(Intent.createChooser(send, c.getString(
R.string.choosertitle_sharevia)));
} catch(android.content.ActivityNotFoundException ex) {
// if no app handles it, do nothing
}
使用:setComponent
//-----核心部分----- 前名一个参数是应用程序的包名,后一个是这个应用程序的主Activity名
Intent intent=new Intent();
intent.setComponent(new ComponentName("com.droidnova.android.games.vortex",
"com.droidnova.android.games.vortex.Vortex"));
startActivity(intent);