Reputation: 79
Google play store is showing crash (I am not able to reproduce) in Xiaomi devices only. Please find crash logs below. I had tried to reproduce this crash in Xiaomi device as well but not able to reproduce.
java.lang.RuntimeException: at android.os.AsyncTask$3.done (AsyncTask.java:309) at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:354) at java.util.concurrent.FutureTask.setException (FutureTask.java:223) at java.util.concurrent.FutureTask.run (FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:234) at 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) Caused by: java.lang.ExceptionInInitializerError: at in.betterbutter.android.emoji.EmojiParse$ParseAsync.doInBackground (EmojiParse.java:30) at 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)
Here is my code:
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;
}
}
}
Upvotes: 1
Views: 2938
Reputation: 2686
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.
Upvotes: 1