Issue
Recently my app crashed and showed the below error. I can't detect what the actual issue is, and also can't detect crash.
If anyone has a solution for this crash then help for this issue.
java.lang.NullPointerException:
at android.app.ActivityThread.updateLocaleListFromAppContext (ActivityThread.java:6107)
at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6354)
at android.app.ActivityThread.access$1300 (ActivityThread.java:220)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1860)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7403)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:935)
Thanks in advance :)
Solution
After a crash analysis and check firebase crashlytics I got the solution of my error. Actual I pass image one activity to another activity and its crash being there.
Activity A
Intent code = new Intent(Activity_A.this, Activity_B.class);
code.putExtra("BitmapImage", bitmap);
startActivity(code);
Activity B
And I retrieve the image in another class
if (getIntent()!= null) {
bitmap = (Bitmap) getIntent().getParcelableExtra("BitmapImage");
}
Solution is: convert bitmap to byte array after pass one activity to another activity like below
Activity A:
Intent code = new Intent(Activity_A.this, Activity_B.class);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
code.putExtra("BitmapImage", byteArray);
startActivity(code);
Activity B:
Bundle extras;
if (intent != null) {
extras = getIntent().getExtras();
byte[] byteArray = extras.getByteArray("BitmapImage");
Bitmap bitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
}
After this code, my issue is solved :)
Answered By - Praful Korat
Answer Checked By - Marilyn (JavaFixing Volunteer)