user256239 user256239 - 2 years ago 98
Android Question

How to start activity in another application?

I have application A defined as below:

<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="com.example.MyExampleActivity"
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

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

Answer Source

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"));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download