I am using Parse to push notifications in android but it crashes eventually on background when i turn wifi off.
it gives me error:
java.lang.RuntimeException: Unable to start receiver com.parse.ParseBroadcastReceiver: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library.
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 on 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 on main activity onCreate method
ConnectionDetector connection = new ConnectionDetector(this);
if (connection.isNetworkAvailable()) {
PushService.setDefaultPushCallback(this, RegisterForget.class);
}
any help please