android - 无法获得隐含的 Intent 来工作

标签 android android-intent

我正在学习如何将隐式 Intent 与 Intent 过滤器一起使用,但到目前为止还无法触发正确的 Activity 。用于触发 Intent 的代码是:

intent = new Intent();
intent.setAction("com.appsculture.intent.action.PLUGIN_RECEIVER");
startActivity(intent);

所需 Activity 的 Intent 过滤器是:

<activity android:name="PluginReceiver">
<intent-filter>
    <action android:name="com.appsculture.intent.action.PLUGIN_RECEIVER"></action>
</intent-filter>
</activity>

我得到的错误是标准的 ActivityNotFound

09-04 17:15:27.827: ERROR/AndroidRuntime(2552): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.appsculture.intent.action.PLUGIN_RECEIVER }

解决方案:只需将 android.intent.category.DEFAULT 类别添加到 intent 过滤器

在那之后就像魅力一样工作

最佳答案

我设法通过简单地将 android.intent.category.DEFAULT 类别添加到 intent 过滤器来解决这个问题。在那之后就像一个魅力。

正如 Commonsware 在对他的回答的评论中指出的那样, Activity 需要一个类别,但服务或广播接收器不需要。

关于android - 无法获得隐含的 Intent 来工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7299029/

相关文章:

java - 有没有办法明确告诉 Android 系统将我的 Intent 解析为当前 Intent 操作的默认应用程序/Activity ?

java - 工具栏菜单不再起作用

android - 如何使用 cordova 插件检测 OTP

Android Studio 不理解 Log 函数

android - onNewIntent 没有被调用

调用市场 URL 时 android Intent.ACTION_VIEW 崩溃

android - ToUri() 不会转换所有额外的 Intent (parcelable、serializable、byte[]..)

java - 是否可以在 Android 的 App 中创建 App Widget?

java - 从当前位置到 poi 的路线 android map v2

java - 从另一个 fragment 单击按钮时更改图像