使用解析库在Android之前,必须先调用Parse.initialize()必须先、Android、initialize、Parse

2023-09-07 15:11:17 作者:。。喜风喜干净

我正在开发一个照片共享应用程序为Android使用的Parse.com平台的后端。

我有一个主要活动在那里我从解析服务器获取的照片,并在这里这次活动我有开始捕捉照片的活动按钮!

当我要上传的解析服务器上的照片将出现问题 - 我得到这个消息:

 您必须使用解析库之前调用Parse.initialize(....)
 

但我已经初始化解析库在我的开机画面的活动 - 在onCreate方法

我也想提一提,该应用程序的工作,但是当我改变了我的主要活动类此问题开始发生!

你有任何想法是什么问题?

解决方案

 进口com.parse.Parse;
    进口android.app.Application;

    公共类应用程序扩展应用{
      @覆盖
      公共无效的onCreate(){
        super.onCreate();

        Parse.enableLocalDatastore(本);
        Parse.initialize(这一点,PARSE_APPLICATION_ID,PARSE_CLIENT_KEY);
      }
    }
 
Android 生成so库 然后给别人调用

AndroidManifest.xml中

 <应用
        机器人:名称=yourpackagename.App
。
。
。
< /用途>
 

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?

解决方案

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>