在Android的应用程序间的通信 [英] Inter Application Communication in Android

查看:108
本文介绍了在Android的应用程序间的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 意向书我=新的意图(这一点,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(ⅰ);
 

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

这篇关于在Android的应用程序间的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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