Hi all having a fierce issue with this Push Notification for android. I set up a Custom receiver. I'm able to send and see the Push Notifications. But when I click on the notification i get the error below.
FATAL EXCEPTION: main
Process: com.rocketapptechnologies.listout, PID: 29566
java.lang.RuntimeException: Unable to start receiver com.rocketapptechnologies.receiver.ParseReceiver: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2586)
at android.app.ActivityThread.access$1700(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1403)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5310)
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:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at android.app.ContextImpl.startActivity(ContextImpl.java:1130)
at android.app.ContextImpl.startActivity(ContextImpl.java:1117)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:311)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:311)
at com.rocketapptechnologies.receiver.ParseReceiver.onPushOpen(ParseReceiver.java:24)
at com.parse.ParsePushBroadcastReceiver.onReceive(ParsePushBroadcastReceiver.java:123)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2579)
at android.app.ActivityThread.access$1700(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1403)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5310)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
But as you can see I have the intent key to start the activity. It's starting to annoy me so hopefully someone will have some experience to share :)
This is my Custom Receiver: package com.rocketapptechnologies.receiver;
import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import com.parse.ParsePushBroadcastReceiver;
import com.rocketapptechnologies.listout.LoginActivity;
/**
* Created by KieranMcc on 20/01/2016.
*/
public class ParseReceiver extends ParsePushBroadcastReceiver {
public ParseReceiver(){
}
@Override
protected void onPushOpen(Context context, Intent intent) {
super.onPushOpen(context, intent);
Intent i = new Intent(context, LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
And this is the ManifestFiles Receiver and Services tags
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
</intent-filter>
</receiver>
<receiver android:name="com.rocketapptechnologies.receiver.ParseReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: Change "com.parse.starter" to match your app's package name.
-->
<category android:name="com.rocketapptechnologies.listout" />
</intent-filter>
</receiver>
Can't find anything to help me just click in the Notification and open the simple Activity I want to test using it.
Thank you for reading my question and really hope ye can help so I can actually continue with my app xD