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.
Related
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?
First off, this has never happened before on any other android device I've used (multiple devices have been tried and tested before this).
Now I have an app that I have worked on for a little over a year now, it is called AutomatedId (on the app store) and it has worked quite well for my company for quite some time.
Recently I have been given a device to add compatibility to the app (specifically for reading UHF tags) but that isn't the problem.
The problem comes whenever you open the app, the screen stops reading inputs completely, as well as buttons cease to function. I turned on developer options to see the screen inputs and as i suspected, it completely stops and does not read any of the inputs after the app is opened. Clicks don't work, buttons don't work, keyboard doesn't open, hardware buttons on the device stop working. It's a mess, does anyone know what could have caused this?
This is a S98 from here: http://www.wepoy.com/product_view_18.html
moved my comment to the answer as you said. This may be due to memory leak. Here are some references that may help you fix them: Fixing-Memory-Leaks-in-Android-Studio & use this library from square to detect memory leaks early: leakcanary
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.
I have incredibly hard problem to pinpoint.
I have a project which is not really important here (actually tested it on other project, same thing, and also on another computer, same thing) with typical hierarchy. Within it I use custom views, and also use custom views from my external library (which initially thought is the cause, but it isn't as the same thing happens with custom views within src of the same project). I use some of those custom views inside my xml's defining views. I had a need to debug some operations going on within one of those custom view classes. So I set couple breakpoints, ran the project, and when the runtime hit them I saw this screen:
As you see the debugging is broken although the breakpoint is hit on exact line I put it. I cannot do anything here though, except resuming it or terminating it. All the "step in/out" options are greyed out, and the stack trace for the main thread is literaly gone.
This happens on the Galaxy S4 (i9500) that I aquired lately. I cannot say for certain, but I'm pretty sure on my previous Galaxy S+ (i9001) it did not happen.
More information for you:
My i9500 is rooted with custom kernel flashed. The DDMS screen also does not show any processes that are going on on my device (was deffinetly showing on galaxy s+ I had before):
As you see, the processes are being shown just fine inside an emulator, but there are no processes (the application process for the project, after I run it is being shown there, but nothing else).
As for emulator, same machine (tested on both), same environment, same projects, and no problems with debugging it whatsoever:
As you see, everything is perfect over here.
Another important information is that it only happens (from what I see) when xml views are being processed. When I create a reference to one of my custom views manually, debugging works as expected on both the emulator, and the device. So far, it only happens when the breakpoint is being hit when the xml view is being processed.
The last piece of information is that my Device Chooser when I deploy application, shows empty space inside the Debug column. I don't know if it's relevant or not.
I've lost almost 5 hours now looking for solution of this problem (and the cause) on the web, without any luck.
From all the circumstances, it seems the problem is with galaxy s4 I have, not with the computer, or the IDE, or the project itself, but the question is, what is the problem. Tried reinstalling samsung drivers, tried uninstalling those and installing PDA.net drivers alone. No help.
If anybody of you will be able to figure out this puzzle, you are God. Besides that, you will have my deepest gratitude, as this issue is driving me nuts.
ps. I have all the android SDK's up to date, and eclipse plugin as well.
Half the answer (so far).
Upon updating to new 4.3 update, and new custom kernel (Perseus Kernel alfa 14), the DEBUG flag is shown in the Device Chooser dialog screen, and is set to YES. Also, the processes are now visible in DDMS.
Unfortunetly, still the stack is empty once the breakpoints are hit in the custom views.
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.