Ido*_*veh 1 crash android parse-platform
每当我打开设备时,我都会看到以下消息:
图片链接(我没有足够的声誉):http://i.stack.imgur.com/TceMS.png
logcat的:
12-19 11:57:47.914: E/com.parse.PushService(18423): The Parse push service cannot start because Parse.initialize has not yet been called. If you call Parse.initialize from an Activity's onCreate, that call should instead be in the Application.onCreate. Be sure your Application class is registered in your AndroidManifest.xml with the android:name property of your <application> tag.
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start service com.parse.PushService@419934e8 with Intent { act=com.google.android.c2dm.intent.REGISTRATION flg=0x10 pkg=com.idonaveh.guess cmp=com.idonaveh.guess/com.parse.PushService (has extras) }: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library.
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2859)
at android.app.ActivityThread.access$1900(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1461)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5371)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
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:634)
at com.parse.Parse.getApplicationContext(Parse.java:236)
at com.parse.ManifestInfo.getContext(ManifestInfo.java:322)
at com.parse.ManifestInfo.getPackageName(ManifestInfo.java:326)
at com.parse.ManifestInfo.getIntentReceivers(ManifestInfo.java:131)
at com.parse.ManifestInfo.hasIntentReceiver(ManifestInfo.java:123)
at com.parse.ManifestInfo.getPushUsesBroadcastReceivers(ManifestInfo.java:174)
at com.parse.PushService.wipeRoutingAndUpgradePushStateIfNeeded(PushService.java:449)
at com.parse.PushService.onStartCommand(PushService.java:430)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2842)
... 10 more
Run Code Online (Sandbox Code Playgroud)
解析初始化:
Parse.initialize(this, "Application ID", "Client Key");
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.saveInBackground();
Run Code Online (Sandbox Code Playgroud)
每次打开我的设备时都会弹出......怎么办?
你应该在Application课堂上打电话给这个,只需要做一次.
import com.parse.Parse;
import android.app.Application;
public class YourApplicationName extends Application {
@Override
public void onCreate() {
super.onCreate();
Parse.enableLocalDatastore(this);
Parse.initialize(this, "PARSE_APPLICATION_ID", "PARSE_CLIENT_KEY");
}
}
Run Code Online (Sandbox Code Playgroud)
在Manifest中声明它是这样的
<application
android:name="yourpackagename.YourApplicationName"
.
.
.
Run Code Online (Sandbox Code Playgroud)
或者如果你想使用你的方法并在每一个中调用它Activity,你将不得不使用getApplicationContext()而不是this.