Otrzymuję wiele raportów od użytkowników o awarii mojej aplikacji. Stały błąd wydaje się być związany z moją inicjalizacją parse.com, jednak ustawiłem to tak, jak opisano w samouczku parse.Awaria runtime w Parse.com - Android
tutaj jest ślad stosu:
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.
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2580)
at android.app.ActivityThread.access$1700(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
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: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library.
at com.parse.Parse.checkContext(Parse.java:606)
at com.parse.Parse.getApplicationContext(Parse.java:214)
at com.parse.ManifestInfo.getContext(ManifestInfo.java:322)
at com.parse.ManifestInfo.getPackageManager(ManifestInfo.java:330)
at com.parse.ManifestInfo.getPackageInfo(ManifestInfo.java:356)
at com.parse.ManifestInfo.deviceSupportsGcm(ManifestInfo.java:441)
at com.parse.ManifestInfo.getPushType(ManifestInfo.java:210)
at com.parse.PushService.startServiceIfRequired(PushService.java:168)
at com.parse.ParseBroadcastReceiver.onReceive(ParseBroadcastReceiver.java:19)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2573)
... 10 more
i tu jest mój kod inicjalizacji:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_screen);
Parse.initialize(this, "hGG5RdgNVdI7eCeZynV32lWYXywQRHkpp5zLdY7Q", "TwmNbpBYEt4u3euE3lzNIgwyroSl8RPGF2dJFsPv");
ParseInstallation.getCurrentInstallation().saveInBackground();
Czy ktoś może zobaczyć, co jest przyczyną tego błędu, i jak to naprawić?
poniżej jest mój kod Odbiornik:
public static class Receiver extends ParsePushBroadcastReceiver {
private String notificationText;
private Boolean notificationreceived = false;
public Receiver(){
}
private static final String TAG = "MyNotificationsReceiver";
@Override
public void onPushOpen(Context context, Intent intent) {
Log.e("Push", "Clicked");
Intent i = new Intent(context, HomeScreen.class);
notificationreceived = true;
i.putExtra("alert",notificationText);
i.putExtra("alertreceived", notificationreceived);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Scb998.scb988b=true;
try {
JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
Scb998.msg = json.getString("alert");
} catch (JSONException e) {
Log.d(TAG, "JSONException: " + e.getMessage());
}
}
}
'Spowodowane przez: java.lang.RuntimeException: applicationContext ma wartość null. Przed użyciem biblioteki Parse należy wywołać funkcję Parse.initialize (context, applicationId, clientKey). " Wygląda na to, że nie zainicjowano poprawnie. – Tyler
@Tyler, jeśli tak jest, czy masz jakieś pomysły na jego prawidłowe zainicjowanie? – scb998
Możesz wypróbować, co mam odpowiedział na ten temat: http://stackoverflow.com/questions/27367362/i-cant-receive-push-notifications-in-app-from-parse/27367613#27367613, aby sprawdzić, czy działa – bjiang