I use Parse for push notifications in android, but it eventually falls into the background when I turn off Wi-Fi.
this gives me an error:
java.lang.RuntimeException: Cannot start the receiver com.parse.ParseBroadcastReceiver: java.lang.RuntimeException: applicationContext is null. Before using the Parse library, you must call Parse.initialize (context, applicationId, clientKey).
here is my code
public class ParseBroadcastReceiverCustom extends BroadcastReceiver { @Override public void onReceive(final Context context, Intent intent) { if(intent == null) return; ConnectionDetector connection = new ConnectionDetector(context); if (connection.isNetworkAvailable()) { PushService.startServiceIfRequired(context); } } }
and in the manifest file
<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" /> <action android:name="com.parse.push.intent.OPEN" /> </intent-filter> </receiver>
and main activities onCreate
ConnectionDetector connection = new ConnectionDetector(this); if (connection.isNetworkAvailable()) { PushService.setDefaultPushCallback(this, RegisterForget.class); }
any help please
source share