安装的两个活动分别在设备上具有以下清单文件:
第一个应用程序的活动在其清单中具有:-
在哪里,package="com.example.tictactoe"
<intent-filter>
<action android:name="com.example.tictactoe.YOYO" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
第二个应用程序的活动在其清单中:-
在哪里,
package="com.example.project"
<intent-filter>
<action android:name="com.example.project.YOYO" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
现在,我想使用以下代码从第三个应用程序启动这些活动之一:
i=new Intent();
i.setAction("YOYO");
i.putExtra("KEY","HII..i am from third app");
startActivity(i);
但执行显示错误:-
03-11 08:12:30.496: E/AndroidRuntime(1744): FATAL EXCEPTION: main
03-11 08:12:30.496: E/AndroidRuntime(1744): android.content.ActivityNotFoundException:
No Activity found to handle Intent { act=ACTION_SEND (has extras) }
您需要提供完整的动作名称;供应mimeType您通过调用在清单中使用设置类型()在你的意图中。
显现 :
<intent-filter>
<action android:name="com.example.tictactoe.YOYO" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
Java :
Intent i=new Intent();
i.setAction("com.example.tictactoe.YOYO");
i.setType("text/plain");
i.putExtra("KEY","HI..i am from third app");
startActivity(i);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)