1

Google Play 商店仅在小米设备中显示崩溃(我无法重现)。请在下面找到崩溃日志。我也曾尝试在小米设备上重现此崩溃,但无法重现。

java.lang.RuntimeException:在 android.os.AsyncTask$3.done (AsyncTask.java:309) 在 java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:354) 在 java.util.concurrent.FutureTask.setException ( FutureTask.java:223) 在 java.util.concurrent.FutureTask.run (FutureTask.java:242) 在 android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:234) 在 java.util.concurrent.ThreadPoolExecutor。 runWorker (ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588) at java.lang.Thread.run (Thread.java:818) 原因:java.lang.ExceptionInInitializerError :在 in.betterbutter.android.emoji.EmojiParse$ParseAsync.doInBackground (EmojiParse.java:30) 在 in.betterbutter.android.emoji.EmojiParse$ParseAsync。doInBackground (EmojiParse.java:19) at android.os.AsyncTask$2.call (AsyncTask.java:295) at java.util.concurrent.FutureTask.run (FutureTask.java:237)

这是我的代码:

public class EmojiParse {

    public void parse(JSONObject jsonObject) {
        new ParseAsync().execute(jsonObject);
    }

    public class ParseAsync extends AsyncTask<JSONObject, Void, Void> {

        @Override
        protected Void doInBackground(JSONObject... params) {
            JSONObject jsonObject = params[0];
            try {
                JSONArray jsonArray = jsonObject.getJSONArray("emojis");
                for (int i = 0; i < jsonArray.length(); ++i) {
                    JSONObject object = jsonArray.getJSONObject(i);
                    String text = object.getString("text");
                    String code = object.getString("code");
                    String surrogates = StringEscapeUtils.unescapeJava(object.getString("surrogates"));


                    EmojiMap emojiMap = new EmojiMap();


                    emojiMap.hashSet.add(code);
                    emojiMap.displayMap.put(text, surrogates);
                    emojiMap.reverseMap.put(surrogates, text);

                }
            } catch (JSONException e) {
                e.printStackTrace();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            return null;
        }
    }

}
4

1 回答 1

1

In xiaomi phones run in background is restricted for enabling it

Setting -> 'Apps' ->installed Apps-> 'Your App -> Background Restrictions -> No Restriction

This is because xiaomi uses Baterry Optimisation defaultly for every Application.

Check this link here for example

Use the given code to move to settings page

Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);

To remove restrictions.

于 2017-11-20T09:41:03.947 回答