Inter Application Communication in Android

2019-05-21 14:31发布

I have an activity in one application that calls the activity of another application. How can be done with intent or any other way. For example in single application, we can do it like:

Intent i = new Intent(this, ActivityTwo.class);
i.putExtra("Value1", "This value is sent by FirstActivity ");

2条回答
孤傲高冷的网名
2楼-- · 2019-05-21 15:18

Declare android action for the Second Activity and call the Second Activity from First Activity through the Action name. For more info see the below example:

Declared Second Activity in AndroidManifest.xml as

<activity android:name=".SecondActivity">
<intent-filter>
<action android:name="com.sample.action.MY_CUSTOM_ACTION"/>
</intent-filter>
</activity>

Then install the second app first and call the SecondActivity as below:

Intent i = new Intent("com.sample.action.MY_CUSTOM_ACTION");
i.putExtra("mystring","Sample Text");//optional.
startActivity(i);
查看更多
贪生不怕死
3楼-- · 2019-05-21 15:24
登录 后发表回答