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!
Related
When there is a configuration change, such as uiMode, Locale, etc., the fragments are not restored correctly. Then simply put the application in the background, and then return to the foreground, and everything is restored.
The problem does not arise in a systematic way, but without a rule, it does not arise until version 10 of Android. Apparently it also depends on the devices, for example with two different brands of phones, with Android 11 installed, on one it will happen and on another it will not happen.
In the attached video you can see the problem when it occurs.
https://drive.google.com/file/d/1nRXG9fqttc8TtTL4tLF0o8haru8A1YNg/view?usp=drive_web (Screen_Recording_20220530-231647_Call Blocker - Phone.mp4)
On say a Samsung Galaxy S3, it's possible via an application's manifest, to allow it to run in multi-screen mode. Thus when it is running, a second application can be dragged onto the screen and each application then has half (or may be different amounts) of the screen.
When an application is running full screen, how can it tell if another application has been dragged onto the screen, and thus it now only has half of the screen real estate?
The activity is not restarted, and the onConfigurationChange method is not invoked.
Section "3-8-9. Handling Layout Changes" in this document http://developer.samsung.com/s-pen-sdk/technical-docs-09 gives the answer.
Note, you don't need the Samsung SDK to detect the change.
So I'm making an app for my company, for a android tablet to be used like a "kiosk". Users should only be able to use this one app, and be able to do nothing else on the tablet.
I've found a solution by using WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED on the activities. However, when I switch to another activity in my app, the leaving activity fades out, shows the lock screen quickly and then the next activity appears.
I'm guessing that this is because the FLAG_SHOW_WHEN_LOCKED is in onCreate(), as opposed to earlier in the Activity creation process.
Is there anywhere else I can put this flag, or any other way to prevent the lockscreen to be shown between activities? It's not a huge issue, but it is a poor user experience.
It is a Samsung Galaxy Tab 10.1 Running ICS 4.0.3.
I was able to best fix this by using Fragments and using FragmentManager to swap out the fragments in the activity, so the lockscreen was never shown, since I never left the activity. The android developer guide has a good example for this.
http://developer.android.com/reference/android/app/Fragment.html
I have an app which has an activity A, that lets the user click on a thumbnail and go to another activity B which shows the thumbnail full screen. On activity B, if the user clicks anywhere on the screen, it closes the activity.
Both activities are defined as portrait in the manifest, and both have the onConfigChange value to contain the orientation flag.
It works perfectly on all versions of Android and all devices that I've tested, except one - Motorola Xoom, with Android 3.1. On the Xoom, if the user navigates quickly between the activities (back and forth), it has a chance to show activity A in landscape mode for a very short time, as if it planned to switch to it.
Not only that, but if it remove the flag of the onConfigChange in the manifest, activity A might re-create itself from scratch on this special case.
What could cause this weird thing? Is it some weird bug on android 3.1 or the Xoom? Is there anyway i can fix this issue? I could have something that blocks the touch on activity B for a few ms on the beginning, but that's just a workaround.
I developed a pretty simple game that uses a custom view for drawing to the screen. On my phone (Android 2.2), I can press the home button on the device and do other tasks. When returning to the game, it is restored to the exact state that it was before. The thing is, I didn't have to override any methods or really do anything for this behavior to occur. However, on Honeycomb, it resets everything like I would expect.
It's very puzzling... I was wondering if there was a way to make Honeycomb behave like 2.2 in this regard. I'm not too familiar with saving view states, but since I have a LOT of variables (hundreds, depending on how custom objects are saved), I imagine it being unpleasant to manually do.
I was able to solve it. Kind of.
Basically, the problem was caused by the way that Android handles the screen being fixed to portrait mode in my activity. In 2.2, Android would open the activity in portrait mode and not restart the activity. However, in Android 3.0, it opens the activity, and THEN rotates the screen, causing it to restart the activity (since that happens when a rotate happens).
To fix this, I added the following to my activity in the manifest:
android:configChanges="keyboardHidden|orientation"
This tells Android that you will handle config changes yourself. In my case, I do nothing, since my application is locked in portrait mode.
The reason the state isn't cleared when the application is paused is because onCreate() doesn't get called. I am aware that Android can kill the application though, which would call onCreate(), so I will still have to handle that situation by saving the Activity variables and recreating the View with them.