未找到 activity 来处理来自广播接收器的意图
no activity found to handle intent from broadcast receiver
我正在尝试从广播接收器中调用主题为 activity 的对话。
我的清单声明如下所示:
<activity android:name=".Views.DialogueActivity"
android:theme="@android:style/Theme.Dialog">
<intent-filter>
<action android:name="com.example.tictactoe.CUSTOM_DIALOGUE" />
</intent-filter>
</activity>
我的广播接收器:
public class WinReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent();
i.setAction("com.example.tictactoe.CUSTOM_DIALOGUE");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}}
我的 Activity 是一个对话主题 activity,我得到一个错误:
FATAL EXCEPTION: main
Process: com.example.akshay.ticktactoe, PID: 18301
java.lang.RuntimeException: Unable to start receiver com.example.akshay.ticktactoe.Views.Helpers.WinReceiver: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.tictactoe.CUSTOM_DIALOGUE flg=0x10000000 }
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2586)
at android.app.ActivityThread.access00(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
好像是什么问题?我是否正确地声明了 activity 的操作?
使用显式 Intent
:Intent i = new Intent(context, DialogueActivity.class);
并从清单中删除 Intent
和 <intent-filter>
中的操作字符串。
仅当第三方应用需要能够直接启动 activity 时才使用 <intent-filter>
。
我正在尝试从广播接收器中调用主题为 activity 的对话。 我的清单声明如下所示:
<activity android:name=".Views.DialogueActivity"
android:theme="@android:style/Theme.Dialog">
<intent-filter>
<action android:name="com.example.tictactoe.CUSTOM_DIALOGUE" />
</intent-filter>
</activity>
我的广播接收器:
public class WinReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent();
i.setAction("com.example.tictactoe.CUSTOM_DIALOGUE");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}}
我的 Activity 是一个对话主题 activity,我得到一个错误:
FATAL EXCEPTION: main
Process: com.example.akshay.ticktactoe, PID: 18301
java.lang.RuntimeException: Unable to start receiver com.example.akshay.ticktactoe.Views.Helpers.WinReceiver: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.tictactoe.CUSTOM_DIALOGUE flg=0x10000000 }
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2586)
at android.app.ActivityThread.access00(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
好像是什么问题?我是否正确地声明了 activity 的操作?
使用显式 Intent
:Intent i = new Intent(context, DialogueActivity.class);
并从清单中删除 Intent
和 <intent-filter>
中的操作字符串。
仅当第三方应用需要能够直接启动 activity 时才使用 <intent-filter>
。