PopupWindows are shown in reversed order after application is resumed - android

On devices with Android >= 4.4.2 I've faced a strange behavior of popupWindows.
If more than 1 window is opened, and you switch to another application, then after you resume first application, all popupWindows will be shown in the reversed order (I mean if you had window1, window2 on top of window1, and window3 on top of previous two, then after app is resumed, you will have window3, window2, window1).
Earlier versions (< 4.4.2) doesn't have this bug (or maybe it is not a bug, and this is supposed to be correct behavior?). And to my shame, I have no idea how to fix this in my app. I appreciate if any can help.

Related

An old activity starts in tablet devices EVEN after I delete it?

I just come into a very weird situation today which is when I use a tablet AVD device, my main activity starts with an old design which I want to change, but when I try changing anything in the UI nothing changes in runtime and android still loads that old activity design.
This happened when I created two activities; the main one for small screens and another with sw-600dp, then changed my mind that I want to change the design for tablets ONLY when they are in landscape orientation. So, I deleted sw-600dp activity and created an activity-land, but the tablet had stuck with the old one and does not change anymore.
I tried deleting the whole main activities to see what happens, however, the app still opens normally with that old activity. I also tried to search for that stuck main activity, maybe it is hidden, but didn't find anything. The strange thing that my code is referencing the activity normally EVEN after I deleted it entirely. Moreover, tried to right click on this reference and go to declaration but it didn't open anything.
Note: when I try another device that is not a tablet it acts as expected that there is not activity and app crashes as expected so there are no problems with these small screen devices.
Here is a screenshot of my activities and how my java code is still - weirdly - referencing an activity that does not exist!

Window setFlags() behaviour differences between Android versions?

I have an Activity, which has a Fragment, inside of which is a ViewPager of images. In the ViewPager, there might be certain images which are sensitive, and the viewer should not be able to take a screenshot of (only) those. When such an item shows, I do:
fragment.getActivty().getWindow().addFlags(FLAG_SECURE).
And then in that fragment's onDestroy (or ViewPager's swipe), I clear that flag on the window.
This works perfectly on Android versions 6.0 and above: when that particular image is open, screenshots are blocked.
However, on Android 5.x and below, the flag update does not take place till there's a configuration change on the hosting Activity.
Does anyone know why this happens? And what's the best workaround?
I found some references here on StackOverflow, talking about the problem and a workaround, but (a) nothing explains why there's this discrepancy and (b) the workaround suggested is very, very high friction: it flashes the entire screen black.
References:
How to disable screen capture in Android fragment?

Android 4.4.4 Webview on Nexus 5 goes blank (or gets frozen) sometimes

I have an hybrid app which has a navigation drawer to go to different links, and a webview to load the content.
The problem that recently surfaced is that sometimes when you resume the app from background on Nexus 5(Android 4.4.4), the webview goes completely blank and there's no way to recover from that state. Clicking on different links in the navigation drawers does nothing. It does even try to load the page. You can't recover until you force kill the app or reinstall.
It happens very intermittently and I have been able to find out the concrete reproducible steps for this. It start happening couple of days back, so I doubt it could be due to the recent update on Chrome Browser, but I'm not very sure.
Anyone else facing similar issue? Any pointers on how can I fix it?

DialogFragment behaves differently when invoked via ActionBar

I'm experiencing strange, perhaps version-specific behavior with my DialogFragment subclass when testing the following steps:
(1) Open the dialog
(2) Leave the app with either the Home key or the Recent Apps key
(3) Return to the app, and the dialog is no longer visible. It seems to be briefly, translucently visible behind the main activity.
(4) Rotate the device, and the dialog re-appears.
This bug occurs on my Asus TF700T pad running Android 4.2.1, and it does not occur on my Motorola Razr phone running Android 4.1.2 (which has a menu key rather than an overflow button). Moreover, it only occurs if the dialog is opened via the overflow menu - dialogs opened via ActionBar items do not exhibit this issue! And finally, the issue does not occur if you do an orientation change before pausing the activity.
I have found a very similar issue which includes depressing comments like "This is clearly an Android bug." There are associated bug reports. Please, say it ain't so...
My workaround for this issue is in onResume(): I check the FragmentManager for existing dialogs with findFragmentByTag; if any are not null I dismiss and re-show them. But I'd like to understand what's really going on here.
I guess the answer to this question is the Google bug report linked above. I changed my design to avoid the problem, so I have not tried the workaround someone there has posted.

Return to second activity after clicking home button

I've tried all launchMode's yet it does not seem to work:
Suppose App A has various activities, J & K. J is the initial one (to choose app mode), which calls K where the main things happen (after calling it, J finish()es). If i click "Home" button in K, and then open the app again, it opens a new instance of A with activity J.
I'd like it to open the paused K activity instead. Other threads mention an Android bug -- is there a way to fix it? Setting launchMode does not work :S
Thanks a lot.
What you want is normal Android behaviour. The fact that it isn't working means that you are probably doing something strange. Do not try to solve this by playing around with launchModes. Please post the relevant parts of your manifest. There is, however, a bug which manifests itself like this. To see if this bug is causing your problem do the following: force-close your app on the phone. Now start your app from the list of apps on the phone. Go from ActivityJ to ActivityK. Press HOME. Open the app again. If it works now, you are just seeing the dreaded Android launch bug.
For more details on the launch bug, see these issues:
http://code.google.com/p/android/issues/detail?id=2373
http://code.google.com/p/android/issues/detail?id=26658
The bug is there on all devices, on all versions of Android (at least up to ICS, haven't tested on JellyBean yet). It all works as it should in the emulator, so you cannot use emulator behaviour as an indication of real device behaviour.

Categories

Resources