已安装两个活动,分别在设备上具有以下清单文件:
Two activities are installed having the following manifest files on device respectively:
第一个应用的活动明显体现在:-在哪里, package ="com.example.tictactoe"
The First app's activity has in its manifest:- where, 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"
The second app's activity has in its manifest:- where, 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>现在,我想使用以下代码从第三个应用程序中启动这些活动之一:
Now, i want to start one of these activity from third application using the following code:
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) } 推荐答案您需要提供完整操作名称;通过在意图中调用 setType()来提供清单中使用的 mimeType .
You need to supply the full action name; supply the mimeType you used in manifest by calling setType() in your intent.
清单:
<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);更多推荐
启动自定义隐式意图
发布评论