如何启动另一个应用程序中的活动? [英] How to start activity in another application?

查看:165
本文介绍了如何启动另一个应用程序中的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经应用程序中的定义如下:

I have application A defined as below:

<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,我怎么能写code,开始在应用程序中的活动?谢谢!

Now in application B, how can I write the code to start the activity in application A? Thanks!

推荐答案

感谢您为您回复。你解决方案仅适用于两个活动是在同一应用程序。就我而言,应用程序B不知道类com.example.MyExampleActivity.class在code,因此编译会失败。

thank you for you reply. You solution only works for two activities that are in the same application. In my case, application B doesn't know class com.example.MyExampleActivity.class in the code, so compile will fail.

我在网上搜索,并发现了一些类似这样的下方,它工作得很好。

I searched on the web and found something like this below, and it works well.

Intent intent = new Intent();
intent.setComponent(new ComponentName("com.example", "com.example.MyExampleActivity"));
startActivity(intent);

这篇关于如何启动另一个应用程序中的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆