Caused by: java.lang.IllegalStateException: ParsePlugins is already initialized

后端 未结 5 2125
甜味超标
甜味超标 2020-12-07 00:50

I quit the app, relaunch it, I am getting an exception.

public void onCreate() {
-->here Parse.initialize(this, \"adfsfasdfs\",
            \"asdfadfsdf\"         


        
5条回答
  •  [愿得一人]
    2020-12-07 01:21

    Parse.initialize() should only be called once for an entire application.

    Calling it in an Activity's onCreate function can cause it to be initialized more than once, as an Activity can be created more than once during an app's lifecycle.

    Instead, create an Application class (and add an android:name attribute to your your application's manifest).

    Application: (Note not an Activity/Service/Reciever)

    //Note that this is an android.app.Application class.
    public class MyApplication extends android.app.Application {
    
    @Override
    public void onCreate() {
        super.onCreate();
    
        //This will only be called once in your app's entire lifecycle.
        Parse.initialize(this,
                getResources().getString(R.string.parse_application_id),
                getResources().getString(R.string.parse_client_key));
    }
    

    AndroidManifest:

    
            ....
            
                ....
            
    
    

提交回复
热议问题