问题描述
我的设置解析推的Android SDK 1.7.0 ,并可以接收推没有任何问题。然而,以下异常打开推送通知我的应用程序崩溃时:
我也试过子类<$c$c>ParsePushBroadcastReceiver$c$c>与 getActivity()
总是返回的主要活动类,同样的结果。下面是完整的堆栈跟踪:
E / AndroidRuntime:致命异常:主要
工艺:com.ers.test,PID:13513
java.lang.RuntimeException的:无法启动接收器com.ers.test.MyPushBroadcastReceiver:android.content.ActivityNotFoundException:无活动处理意向{行为= android.intent.action.VIEW DAT = FLG = 0x1000c000(有群众演员)}
在android.app.ActivityThread.handleReceiver(ActivityThread.java:2452)
在android.app.ActivityThread.access $ 1700(ActivityThread.java:144)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1281)
在android.os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:136)
在android.app.ActivityThread.main(ActivityThread.java:5146)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:515)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:796)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
在dalvik.system.NativeStart.main(本机方法)
android.content.ActivityNotFoundException:产生的原因无活动处理意向{行为= android.intent.action.VIEW DAT = FLG = 0x1000c000(有群众演员)}
在android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
在android.app.Instrumentation.execStartActivitiesAsUser(Instrumentation.java:1481)
在android.app.ContextImpl.startActivitiesAsUser(ContextImpl.java:1136)
在android.content.ContextWrapper.startActivitiesAsUser(ContextWrapper.java:344)
在android.content.ContextWrapper.startActivitiesAsUser(ContextWrapper.java:344)
在android.app.TaskStackBuilder.startActivities(TaskStackBuilder.java:221)
在android.app.TaskStackBuilder.startActivities(TaskStackBuilder.java:232)
在android.app.TaskStackBuilder.startActivities(TaskStackBuilder.java:208)
在com.parse.TaskStackBuilderHelper.startActivities(TaskStackBuilderHelper.java:19)
在com.parse.ParsePushBroadcastReceiver.onPushOpen(ParsePushBroadcastReceiver.java:202)
在com.parse.ParsePushBroadcastReceiver.onReceive(ParsePushBroadcastReceiver.java:108)
在android.app.ActivityThread.handleReceiver(ActivityThread.java:2445)
在android.app.ActivityThread.access $ 1700(ActivityThread.java:144)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1281)
在android.os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:136)
在android.app.ActivityThread.main(ActivityThread.java:5146)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:515)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:796)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
在dalvik.system.NativeStart.main(本机方法)
花费几个小时后。找到了解决办法:实现你的接收器和扩展ParsePushBroadcastReceiver类。
Receiver.java
公共类接收器扩展ParsePushBroadcastReceiver {
@覆盖
公共无效onPushOpen(上下文的背景下,意图意图){
Log.e(推,点击);
意图I =新的意图(背景下,HomeActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(ⅰ);
}
}
使用它的清单,(而不是使用ParsePushBroadcastReceiver的)
code项目的清单:
&LT;接收器
机器人:名称=your.package.name.Receiver
机器人:出口=假&GT;
&LT;意向滤光器&gt;
&lt;作用机器人:名称=com.parse.push.intent.RECEIVE/&GT;
&lt;作用机器人:名称=com.parse.push.intent.DELETE/&GT;
&lt;作用机器人:名称=com.parse.push.intent.OPEN/&GT;
&所述; /意图滤光器&gt;
&LT; /接收器&GT;
编码快乐!
I setup Parse push Android SDK 1.7.0 and can receive pushes without any problem. However, when opening the push notification my app crashes with the following exception:
I also tried subclassing ParsePushBroadcastReceiver
with getActivity()
always returning the main activity class, same result. Below is the full stacktrace:
E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.ers.test, PID: 13513
java.lang.RuntimeException: Unable to start receiver com.ers.test.MyPushBroadcastReceiver: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= flg=0x1000c000 (has extras) }
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2452)
at android.app.ActivityThread.access$1700(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= flg=0x1000c000 (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
at android.app.Instrumentation.execStartActivitiesAsUser(Instrumentation.java:1481)
at android.app.ContextImpl.startActivitiesAsUser(ContextImpl.java:1136)
at android.content.ContextWrapper.startActivitiesAsUser(ContextWrapper.java:344)
at android.content.ContextWrapper.startActivitiesAsUser(ContextWrapper.java:344)
at android.app.TaskStackBuilder.startActivities(TaskStackBuilder.java:221)
at android.app.TaskStackBuilder.startActivities(TaskStackBuilder.java:232)
at android.app.TaskStackBuilder.startActivities(TaskStackBuilder.java:208)
at com.parse.TaskStackBuilderHelper.startActivities(TaskStackBuilderHelper.java:19)
at com.parse.ParsePushBroadcastReceiver.onPushOpen(ParsePushBroadcastReceiver.java:202)
at com.parse.ParsePushBroadcastReceiver.onReceive(ParsePushBroadcastReceiver.java:108)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2445)
at android.app.ActivityThread.access$1700(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
at dalvik.system.NativeStart.main(Native Method)
After spending few hours. Found a solution:Implement your receiver and extends ParsePushBroadcastReceiver class.
Receiver.java
public class Receiver extends ParsePushBroadcastReceiver {
@Override
public void onPushOpen(Context context, Intent intent) {
Log.e("Push", "Clicked");
Intent i = new Intent(context, HomeActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
Use it in manifest, (Instead of using ParsePushBroadcastReceiver)
Code for project's manifest:
<receiver
android:name="your.package.name.Receiver"
android:exported="false" >
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
Happy Coding!!
这篇关于异常开放解析推送通知时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!