作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
安装了两个 Activity ,分别在设备上具有以下 list 文件:
第一个应用程序的 Activity 在其 list 中有:-在哪里, 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>
第二个应用程序的 Activity 在其 list 中有:-在哪里,
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>
现在,我想使用以下代码从第三个应用程序启动这些 Activity 之一:
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) }
最佳答案
您需要提供完整的操作名称;通过在您的 Intent 中调用 setType() 来提供您在 list 中使用的 mimeType。
list :
<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);
关于android - 启动自定义隐式 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15333933/
我是一名优秀的程序员,十分优秀!