如何在另一个应用程序中启动活动?我的应用程序A定义如下:<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="com.example.MyExampleActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity></application>现在在应用程序B中,如何编写代码来启动应用程序A中的活动?谢谢!
3 回答
![?](http://img1.sycdn.imooc.com/5333a1920001d36402200220-100-100.jpg)
BIG阳
TA贡献1859条经验 获得超6个赞
如果两个应用程序具有相同的签名(意味着两个APPS都是您的,并使用相同的密钥签名),您可以按如下方式调用其他应用程序活动:
Intent LaunchIntent = getActivity().getPackageManager().getLaunchIntentForPackage(CALC_PACKAGE_NAME);startActivity(LaunchIntent);
希望能帮助到你。
![?](http://img1.sycdn.imooc.com/533e52b90001456f02000200-100-100.jpg)
慕森卡
TA贡献1806条经验 获得超8个赞
您不需要两个应用程序都具有相同的签名。例如,您可以使用以下方法启动Google地图:Intent i = getPackageManager()。getLaunchIntentForPackage(“com.google.android.apps.maps”)
- 3 回答
- 0 关注
- 370 浏览
添加回答
举报
0/150
提交
取消