Fixed
Status Update
Comments
ra...@google.com <ra...@google.com> #2
I see same issue and have been debugging it.
NOTE: It DOES NOT happen if not using support package, but use android level 14/15 library. I believe Honeycomb works well too.
My current workaround is to provide my own DialogFragment.show() method, like below:
public int show(FragmentTransaction transaction, String tag) {
return show(transaction, tag, false);
}
public int show(FragmentTransaction transaction, String tag, boolean allowStateLoss) {
transaction.add(this, tag);
mRemoved = false;
mBackStackId = allowStateLoss ? transaction.commitAllowingStateLoss() : transaction.commit();
return mBackStackId;
}
NOTE: It DOES NOT happen if not using support package, but use android level 14/15 library. I believe Honeycomb works well too.
My current workaround is to provide my own DialogFragment.show() method, like below:
public int show(FragmentTransaction transaction, String tag) {
return show(transaction, tag, false);
}
public int show(FragmentTransaction transaction, String tag, boolean allowStateLoss) {
transaction.add(this, tag);
mRemoved = false;
mBackStackId = allowStateLoss ? transaction.commitAllowingStateLoss() : transaction.commit();
return mBackStackId;
}
wi...@gmail.com <wi...@gmail.com> #3 Restricted
Restricted
Comment has been deleted.
le...@leonandann.org <le...@leonandann.org> #4
But Google pls fix this issue, as the expected behaviors must be consistent with ICS DialogFragment + FragmentManager and support package DialogFragment + FragmentManager.
It happens with both Support Package v4 r6 and v13 r6.
It happens with both Support Package v4 r6 and v13 r6.
le...@leonandann.org <le...@leonandann.org> #5
I have this problem too.
As a workaround I use a boolean in the onActivityResult to mark the desired dialog and show the dialog in the onResume.
As a workaround I use a boolean in the onActivityResult to mark the desired dialog and show the dialog in the onResume.
le...@leonandann.org <le...@leonandann.org> #7
This is definitely not a bug. There are times when onActivityResult() can be called before the Activity has restored its saved state... committing fragment transactions in these situations will simply not be remembered as a result (see this blog post: http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html ).
Try moving your commits into "onPostResume()" instead as described here:http://stackoverflow.com/questions/16265733/failure-delivering-result-onactivityforresult/18345899#18345899
Try moving your commits into "onPostResume()" instead as described here:
so...@google.com <so...@google.com> #8
Adding a "super.onActivityResult(requestCode, resultCode, data)" call at the beginning of the method seems to fix the problem. I'm surprised than almost nobody came up with such a simple solution.
le...@leonandann.org <le...@leonandann.org> #9
Dear alockw...@google.com,
Let's say we have an application where we need to select a picture from gallery, and then when we come back to onActivityResult(), we need to show a DialogFragment asking the user if he really wants to send the file.
How do you propose we can implement this with the current API?
Thank you,
Sabin
Let's say we have an application where we need to select a picture from gallery, and then when we come back to onActivityResult(), we need to show a DialogFragment asking the user if he really wants to send the file.
How do you propose we can implement this with the current API?
Thank you,
Sabin
so...@google.com <so...@google.com> #10
Please also consider how to deal with "Avoid performing transactions inside asynchronous callback methods." problem which is stated in http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html#more
dismissAllowingStateLoss() is the least resort for dismiss() dialog in onPostExecute(), but there is no solution for DialogFragment#show() in onPreExecute() callback.
dismissAllowingStateLoss() is the least resort for dismiss() dialog in onPostExecute(), but there is no solution for DialogFragment#show() in onPreExecute() callback.
le...@leonandann.org <le...@leonandann.org> #11
I have a similar problem, but I show the DialogFragment (not the one of the support library) on the onStart method call.
How could it be? And, how can I solve this?
How could it be? And, how can I solve this?
so...@google.com <so...@google.com>
le...@leonandann.org <le...@leonandann.org> #12
Still a bug on android 6
so...@google.com <so...@google.com> #13
public void showAllowingStateLoss(FragmentManager manager, String tag) {
FragmentTransaction ft = manager.beginTransaction();
ft.add(this, tag);
ft.commitAllowingStateLoss();
}
I looked up the source code and got this method. I'm wondering why Google add a @hide annotation to this great API?
FragmentTransaction ft = manager.beginTransaction();
ft.add(this, tag);
ft.commitAllowingStateLoss();
}
I looked up the source code and got this method. I'm wondering why Google add a @hide annotation to this great API?
le...@leonandann.org <le...@leonandann.org> #14
Agree #14.
co...@gmail.com <co...@gmail.com> #15
Just looked up source code and this method was introduced since API 23. So maybe here's another alternative:
getFragmentManager().beginTransaction()
.add(fragment, tag)
.commitAllowingStateLoss();
getFragmentManager().beginTransaction()
.add(fragment, tag)
.commitAllowingStateLoss();
co...@gmail.com <co...@gmail.com> #16
Oh my god..
This error happened to my app users..
Please refer to below logs.
Samsung Galaxy Note10+ 5G (d2x), Android 9
java.lang.IllegalStateException:
at androidx.fragment.app.FragmentManager.checkStateLoss (FragmentManager.java:1997)
at androidx.fragment.app.FragmentManager.enqueueAction (FragmentManager.java:2029)
at androidx.fragment.app.BackStackRecord.commitInternal (BackStackRecord.java:321)
at androidx.fragment.app.BackStackRecord.commit (BackStackRecord.java:286)
at androidx.fragment.app.DialogFragment.show (DialogFragment.java:156)
at com.xxx.yyyyy.ZZZActivity$8$1.run (ZZZActivity.java:585)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:216)
at android.app.ActivityThread.main (ActivityThread.java:7263)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:975)
This error happened to my app users..
Please refer to below logs.
Samsung Galaxy Note10+ 5G (d2x), Android 9
java.lang.IllegalStateException:
at androidx.fragment.app.FragmentManager.checkStateLoss (FragmentManager.java:1997)
at androidx.fragment.app.FragmentManager.enqueueAction (FragmentManager.java:2029)
at androidx.fragment.app.BackStackRecord.commitInternal (BackStackRecord.java:321)
at androidx.fragment.app.BackStackRecord.commit (BackStackRecord.java:286)
at androidx.fragment.app.DialogFragment.show (DialogFragment.java:156)
at com.xxx.yyyyy.ZZZActivity$8$1.run (ZZZActivity.java:585)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:216)
at android.app.ActivityThread.main (ActivityThread.java:7263)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:975)
Description
We've encountered a rather odd error that looks like dex2oat is sometimes generating incorrect code for some arithmetic operations.
The problem was first noticed in a banking app protected with obfuscation technology, and the problematic code happened to be doing key generation as part of this obfuscation. However we've isolated it down to a simple example app that just does a tiny bit of maths.
The problem only affects some devices, and we've yet to work out the logic behind when it happens - some devices of a particular model/OS version/manufacturer will have the problem but other apparently-identical devices don't have the problem.
On devices where it occurs, it seems to happen on successive installs (or upgrades) of the app. So the app would work fine, but if you either upgrade it or uninstall and install it, it'll misbehave. Then after the next uninstall/re-install it'll work fine. It's always regular as clockwork - every other install has the issue.
The attached sample app just does some maths and logs the results to logcat in the main activity's onCreate.
public class MainActivity extends AppCompatActivity {
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, android.app.Activity
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
Log.e("Test", "i = -512667375");
Log.e("Test", "i2 = 0");
Log.e("Test", "Method Length " + MainActivity.class.getMethods().length);
int i = MainActivity.class.getMethods().length < 1 ? (int) (0 | 94937813634376546L) : 0;
int i2 = (-512667375) >>> i;
Log.e("Test", "i3 = " + i2);
int i3 = (-512667375) << ((-i) & 31);
Log.e("Test", "i4 = " + i3);
Log.e("Test", "Value is - " + ((i2 + i3) - (i3 & i2)));
}
}
The first time it’s installed, the value printed at the end is -512667375. If the app is re-installed (on an affected device) then all the intermediate values are the same but the final number becomes 0. This is clearly wrong as it means that final sum is coming up with different answers given the same inputs, which isn’t how arithmetic is supposed to work!
Oddly the call to getMethods() is necessary; if it's removed, the whole thing works, despite the number of methods always being more than 0.
If we could understand when this happened (which arithmetic operations were affected and what other things need to be happening for it to occur) we might be able to code round it, but as it is, it's sufficiently baffling that we are stuck.