在Android的应用程序间的通信应用程序、通信、Android

2023-09-06 18:57:16 作者:杀我别用感情刀

我有一个应用程序调用其他应用程序的活动的活动。怎样才能意图或其他任何方式进行。例如,在单一的应用程序,我们可以做到这一点,如:

 意向书我=新的意图(这一点,ActivityTwo.class);
i.putExtra(值1,该值由FirstActivity发送);
 

解决方案

声明的第二个活动Android的动作,并通过行动名字叫从第一个活动的第二项活动。欲了解更多信息请参见下面的例子:

宣布第二个活动在AndroidManifest.xml中的

 <活动机器人:名称=。SecondActivity>
<意向滤光器>
<作用机器人:名称=com.sample.action.MY_CUSTOM_ACTION/>
&所述; /意图滤光器>
< /活性GT;
 

那么首先安装第二个应用程序,并调用SecondActivity如下:

 意向书我=新的意向书(com.sample.action.MY_CUSTOM_ACTION);
i.putExtra(MyString的,示例文本); //可选。
startActivity(ⅰ);
 
Android应用程序UI架构

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 ");

解决方案

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);