Parse.initialize冻结我的应用程序我的、应用程序、Parse、initialize

2023-09-08 08:42:54 作者:彼岸花谢、满地忧伤

我最近升级我的解析 - *。jar文件到1.10.0版本在机器人工作室清理我的项目,并与同步的gradle后,突然我的​​应用程序冻结在开始...... blackscreen,没有任何按钮的工作(我需要强制关闭应用程序)

我搜索了网,这个网站的解决方案,但没有发现任何东西。

任何帮助将非常AP preciated!

我的应用类:

 公共类应用扩展android.app.Application {    @覆盖    公共无效的onCreate(){        super.onCreate();        Log.d(应用程序,reached1);        //启用本地数据存储。        Parse.enableLocalDatastore(本);        Log.d(应用程序,reached2);        ParseObject.registerSubclass(FoodListItem.class);        Log.d(应用程序,reached3);        Parse.initialize(这一点,STRING1,STRING2);        Log.d(应用程序,reached4);        。ParseInstallation.getCurrentInstallation()saveInBackground();        Log.d(应用程序,reached5);        ParsePush.subscribeInBackground(,新SaveCallback(){            @覆盖            公共无效完成(ParseException的E){                如果(E == NULL){                    Log.d(应用程序,成功订阅广播频道。);                }其他{                    Log.e(应用程序,未能认购推,E);                }            }        });} 

logcat的:

  08-17 21:46:58.554 17633-17633 / il.ac.huji.freefood D / dalvikvm:晚启用CheckJNI08-17 21:46:58.594 17633-17633 / il.ac.huji.freefood W / ActivityThread:应用il.ac.huji.freefood可以在端口8100进行调试...08-17 21:46:58.604 17633-17633 / il.ac.huji.freefood D /应用:reached108-17 21:46:58.604 17633-17633 / il.ac.huji.freefood D /应用:reached208-17 21:46:58.614 17633-17633 / il.ac.huji.freefood D /应用:reached3 

在此先感谢!

几个手机使用的小技巧推荐你

修改

我的清单:

 <?XML版本=1.0编码=UTF-8&GT?;<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android    包=il.ac.huji.freefood>    <采用-SDK安卓的minSdkVersion =11/>    <使用许可权的android:NAME =android.permission.INTERNET对/>    <使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>    <使用许可权的android:NAME =android.permission.VIBRATE/>    <使用许可权的android:NAME =android.permission.WAKE_LOCK/>    <使用许可权的android:NAME =android.permission.GET_ACCOUNTS/>    <使用许可权的android:NAME =com.google.android.c2dm.permission.RECEIVE/>    <使用许可权的android:NAME =android.permission.ACCESS_FINE_LOCATION/>    <许可        机器人:名字=il.ac.huji.freefood.permission.C2D_MESSAGE        安卓的ProtectionLevel =签名/>    <使用许可权的android:NAME =il.ac.huji.freefood.permission.C2D_MESSAGE/>    <应用        机器人:名字=il.ac.huji.freefood.Application        机器人:allowBackup =真        机器人:图标=@绘制/ ic_launcher        机器人:标签=@字符串/ APP_NAME        机器人:主题=@风格/ AppTheme        >        <活动机器人:activities_one_class.MainActivityNAME = />        <活动机器人:activities_one_class.NoFoodFoundActivityNAME = />        <活动机器人:activity_choose_food.ChooseFoodActivityNAME = />        <活动机器人:activity_add_food.AddFoodActivityNAME = />        <活动机器人:名字=。GPS_tracker_Activity/>        <活动机器人:activities_one_class.SignUpActivityNAME = />        <活动机器人:名字=。activities_one_class.LoginActivity>            &所述;意图滤光器>                <作用机器人:名字=android.intent.action.MAIN/>                <类机器人:名字=android.intent.category.LAUNCHER/>            &所述; /意图滤光器>        < /活性GT;        <服务机器人:名字=com.parse.PushService/>        <接收机器人:名字=com.parse.GcmBroadcastReceiver            机器人:权限=com.google.android.c2dm.permission.SEND>            &所述;意图滤光器>                <作用机器人:名字=com.google.android.c2dm.intent.RECEIVE/>                <作用机器人:名字=com.google.android.c2dm.intent.REGISTRATION/>                <类机器人:名字=il.ac.huji.freefood/>            &所述; /意图滤光器>        < /接收器>        <接收            机器人:名字=il.ac.huji.freefood.PushNotificationsReceiver            机器人:出口=假>            &所述;意图滤光器>                <作用机器人:名字=android.intent.action.BOOT_COMPLETED/>                <作用机器人:名字=android.intent.action.USER_ preSENT/>                <作用机器人:名字=com.parse.push.intent.RECEIVE/>                <作用机器人:名字=com.parse.push.intent.OPEN/>                <作用机器人:名字=com.parse.push.intent.DELETE/>            &所述; /意图滤光器>        < /接收器>        &所述;元数据            机器人:名字=com.parse.push.notification_icon            机器人:资源=@绘制/ pooh_icon/>        !<  -  TODO一旦有人安卓资源=@绘制/ ic_launcher/>  - >    < /用途>< /清单> 

解决方案

要任何人谁可能会担心,显然有对手机没有互联网连接(因为它会自动进入USB绑定和出事了那边),使当解析得到初始化它试图连接到服务器AT没有成功为主线,造成冻结效果。

解决的办法是检查手机的连接开始之前解析,所以我最终的解决方案是 -

 公共类应用扩展android.app.Application {@覆盖公共无效的onCreate(){    super.onCreate();    Log.d(应用程序,reached1);    如果(!connectedToInternet()){        Log.e(应用程序,未连接互联网正在退出。);        exitAppWithDialog(本);    }    ....} 

我选择的方法之一来检查哪些这里存在连接 - How检查在Android上网吗? InetAddress类从不超时...

有一个好的一天!

I recently upgraded my parse-*.jar files to version 1.10.0 After cleaning up my project at android studio and syncing with gradle, suddenly my app freezes at start... blackscreen, without any button working (I need to force-close the app)

I searched the net and this site for solutions, but couldn't find anything.

Any help will be much appreciated!

My Application class:

public class Application extends android.app.Application {

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("app", "reached1");

        // Enable Local Datastore.
        Parse.enableLocalDatastore(this);
        Log.d("app", "reached2");

        ParseObject.registerSubclass(FoodListItem.class);
        Log.d("app", "reached3");

        Parse.initialize(this, "STRING1", "STRING2");
        Log.d("app", "reached4");

        ParseInstallation.getCurrentInstallation().saveInBackground();

        Log.d("app", "reached5");


        ParsePush.subscribeInBackground("", new SaveCallback() {
            @Override
            public void done(ParseException e) {
                if (e == null) {
                    Log.d("app", "successfully subscribed to the broadcast channel.");
                } else {
                    Log.e("app", "failed to subscribe for push", e);
                }
            }
        });
}

logcat:

08-17 21:46:58.554  17633-17633/il.ac.huji.freefood D/dalvikvm﹕ Late-enabling CheckJNI
08-17 21:46:58.594  17633-17633/il.ac.huji.freefood W/ActivityThread﹕ Application il.ac.huji.freefood can be debugged on port 8100...
08-17 21:46:58.604  17633-17633/il.ac.huji.freefood D/app﹕ reached1
08-17 21:46:58.604  17633-17633/il.ac.huji.freefood D/app﹕ reached2
08-17 21:46:58.614  17633-17633/il.ac.huji.freefood D/app﹕ reached3

Thanks in advance!

EDIT:

my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="il.ac.huji.freefood" >

    <uses-sdk android:minSdkVersion="11" />


    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <permission
        android:name="il.ac.huji.freefood.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="il.ac.huji.freefood.permission.C2D_MESSAGE" />


    <application
        android:name="il.ac.huji.freefood.Application"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        >

        <activity android:name=".activities_one_class.MainActivity" />
        <activity android:name=".activities_one_class.NoFoodFoundActivity" />
        <activity android:name=".activity_choose_food.ChooseFoodActivity" />
        <activity android:name=".activity_add_food.AddFoodActivity" />
        <activity android:name=".GPS_tracker_Activity" />
        <activity android:name=".activities_one_class.SignUpActivity" />
        <activity android:name=".activities_one_class.LoginActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service android:name="com.parse.PushService" />
        <receiver android:name="com.parse.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="il.ac.huji.freefood" />
            </intent-filter>
        </receiver>

        <receiver
            android:name="il.ac.huji.freefood.PushNotificationsReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.USER_PRESENT" />

                <action android:name="com.parse.push.intent.RECEIVE" />
                <action android:name="com.parse.push.intent.OPEN" />
                <action android:name="com.parse.push.intent.DELETE" />
            </intent-filter>
        </receiver>

        <meta-data
            android:name="com.parse.push.notification_icon"
            android:resource="@drawable/pooh_icon" />

        <!--TODO once it was android:resource="@drawable/ic_launcher" />-->

    </application>
</manifest>

解决方案

To anyone who might be concerned, Apparently there was no Internet connection for the phone (because it automatically went into USB tethering and something went wrong over there) so that when parse got initialized it tried to connect to the server AT THE MAIN THREAD without success, causing the freeze effect.

The solution was to check for the phone's connectivity BEFORE starting parse, so my final solution was -

public class Application extends android.app.Application {

@Override
public void onCreate() {
    super.onCreate();
    Log.d("app", "reached1");
    if (!connectedToInternet()) {
        Log.e("app", "not connected to internet. exiting");
        exitAppWithDialog(this);
    }
    ....
}

I chose one of the methods to check connectivity which exist here - How to check internet access on Android? InetAddress never timeouts...

Have a good day!