You must call Parse.initialize() before using Pars

2019-02-26 06:15发布

问题:

I'm developing a photo sharing app for Android that uses the Parse.com platform for the backend.

I have a Main Activity where I'm fetching the photos from the Parse server and also here in this activity I have a button that starts a capture photo activity!

The problem occurs when I want to upload the photo on the Parse server - I get this message:

You must call Parse.initialize(....) before using Parse library 

but I'm already initializing Parse library in my Splash Screen activity - in the onCreate method!

I also wanted to mention that the app worked but when I've changed the Main Activity class this problems started to occur!

Do you have any idea what is the problem?

回答1:

import com.parse.Parse;
    import android.app.Application;

    public class App extends Application {
      @Override
      public void onCreate() {
        super.onCreate();

        Parse.enableLocalDatastore(this);
        Parse.initialize(this, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY);
      }
    }

AndroidManifest.xml

<application
        android:name="yourpackagename.App"
.
.
.
</application>