如何在另一个应用程序中启动活动?

如何在另一个应用程序中启动活动?

我的应用程序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中的活动?谢谢!


呼如林
浏览 371回答 3
3回答

BIG阳

如果两个应用程序具有相同的签名(意味着两个APPS都是您的,并使用相同的密钥签名),您可以按如下方式调用其他应用程序活动:Intent&nbsp;LaunchIntent&nbsp;=&nbsp;getActivity().getPackageManager().getLaunchIntentForPackage(CALC_PACKAGE_NAME);startActivity(LaunchIntent);希望能帮助到你。

慕森卡

您不需要两个应用程序都具有相同的签名。例如,您可以使用以下方法启动Google地图:Intent i = getPackageManager()。getLaunchIntentForPackage(“com.google.android.apps.maps”)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Android