我是靠谱客的博主 谨慎日记本,这篇文章主要介绍Android基础:通过Intent实现进程间通信(两个应用之间),现在分享给大家,希望可以做个参考。

两个应用之间进程间通信,主要通过Intent的隐式意图来实现,主要包括:action、catagory、DataAndType

action可以理解为就是一个字符串匹配;

catagory范畴,Android不允许android.intent.action.MAIN的activity通过隐式意图启动,所以一般设置为android.intent.category.DEFAULT

catagory一般不要随便写,用系统的。

DataAndType:数据和MIME类型,

如果没有数据Data可以设置为Uri.EMPTY,

TYPE可以随便写:<data android:mimeType="tom/HuoDongActivity" /> 但是如果要用内容提供者的话有特殊要求

<application
     android:icon= "@drawable/ic_launcher"
     android:label= "@string/app_name"
     android:theme= "@style/AppTheme"  >
     <activity android:name= ".TestView"  >
         <intent-filter>
             <action android:name= "android.intent.action.PICK"  />
 
             <category android:name= "android.intent.category.DEFAULT"  />
 
             <data android:mimeType= "tom/HuoDongActivity"  />
         </intent-filter>
     </activity>
</application>

 

Intent intent = new  Intent( "android.intent.action.PICK" );
intent.setDataAndType(Uri.EMPTY, "tom/HuoDongActivity" );
intent.addCategory( "tom" );
startActivity(intent);

 本文转自demoblog博客园博客,原文链接http://www.cnblogs.com/0616--ataozhijia/archive/2012/11/01/2750244.html如需转载请自行联系原作者


demoblog

最后

以上就是谨慎日记本最近收集整理的关于Android基础:通过Intent实现进程间通信(两个应用之间)的全部内容,更多相关Android基础内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部