ParseInstaller.getCurrentInstallation().saveInBackground()冻结了我的应用程序

h_k*_*h_k 13 android parse-platform

我发现大约1/5的测试都是冻结的,经过一些搜索后我把它缩小到了直线:

.ParseInstallation.getCurrentInstallation()saveInBackground();

我正在使用Parse 1.5.1和Android 4.4.2设备.我的应用程序类看起来像:

public class InitApplication extends Application {

 @Override
    public void onCreate() {
        super.onCreate();
        Parse.initialize(this, "my_App_ID", "my_Client_Key");
        PushService.setDefaultPushCallback(this, MainActivity.class);
        System.out.println("execution DOES reach here");
        ParseInstallation.getCurrentInstallation().saveInBackground();
    System.out.println("execution DOES NOT reach here");
    }
}
Run Code Online (Sandbox Code Playgroud)

我的设备上的行为是,我将首先看到一个空白的白色屏幕约5秒钟,然后屏幕变黑.我不确定屏幕保持黑色多长时间,因为我通常会强行关闭.我让它静置了大约10分钟,没有任何变化.我无法按下后退按钮,屏幕上的任何触摸都不起作用.我被迫使用我的主页按钮,然后强制关闭应用程序.重新打开应用程序后,它的行为和功能正常.

进一步的研究让我找到了这篇文章:https://www.parse.com/questions/android-saveinbackground-lock-the-main-thread

但是,我仍然无法找到解决方案.上述帖子中的一个建议是简单地移动此代码的位置.我在主要活动的onCreate()方法之后尝试了这一点(不要与应用程序的onCreate()方法混淆).行为似乎是正常的,直到我到达调用getCurrentInstallation.saveInBackground()代码的位置,我的应用程序冻结并且无法响应,直到我强制关闭它.

这个问题有什么解决方案吗?

Nic*_*ang 3

我在使用 Parse SDK 1.5.1 时也遇到了同样的问题。

我刚刚下载了最新的 SDK 1.6.0 并解决了问题。

下载最新 SDK 的链接。