Android wear: white screen above activity at start up + when resume
Hello,
I'm having a strange behaviour with my android wear app. My app structure is basically: a loading activity that starts another activity which contains 4 fragments and the user can slide between those fragments.
The strange behaviour happens randomly but with the same pattern: a white screen appears "above" my activity/fragment and I have to dismiss it (android wear style: swiping on the left) to access my activity/fragment. This happens either on first start up of the app or after I clicked on the physical button of the watch and resume the app by clicking back on its icon in the app's list of the wear.
What I tried already is the following:
I put breakpoints on the onCreate of Activity and Fragment, but the debugger does not stop on it when this white screen appears. I concluded that this white screen is neither an activity nor a fragment.
I also removed all the "pop up" elements such as Toast and so, which I first thought were the root cause of my problem.
I also tried to follow the different advices of "how to remove white screen at start up" (such as putting in the manifest "@android:style/Theme.Translucent.NoTitleBar.Fullscreen", setting the "android:windowBackground" to another color and so) but it didn't resolve my problem.
I also looked up for post on stack overflow (the closest I found is this one: Pressing home button on Android - white screen when resuming app) but I didn't find any solution yet.
My problem happens both on emulator and real wear device (I'm using a moto 360).
Has somebody else experienced the same problem? Anybody has an idea where I could look further?
Thank you a lot in advance for your help, I'm really stuck and don't know what else to do.
Best,
Jenny
Related
I have a program called Fred (names have been changed to protect the innocent) which I created in embedded Visual C++ 3.0 targetted for the Pocket PC 2002 platform.
The main dialog is a blank dialog - that is, it contains no controls.
When Fred starts, it shows this dialog for a split second, then executes what I call a Dialog Driver. This is simply some code that decides in what order to show other dialogs.
This driver shows the first dialog proper - the entry screen for the application with various option buttons. Depending on what button the user presses, they are taken through a series of dialogs, entering information as they go.
It is the dialog driver's responsibility to show the correct dialog, let it dismiss itself, then display the next one, so that there are at most two dialogs in existence at one time (the blank dialog and the one the user sees). This is opposed to the other traditional method of making each dialog itself display the next dialog in the sequence, with potentially tens of dialogs all laid on top of each other.
Here is the thing: on the XDA I, Fred works seamlessly. You always get a split-second pause between dismissing one dialog and showing the next. In this split second, you see the underlying blank dialog and the user thinks nothing of it.
On the XDA II however, the pause still occurs between one dialog and the next, but this time it sometimes lasts significantly longer. We're talking several seconds of seeing the blank dialog and there is no pattern to when this occurs.
On one occasion, we spent 4 minutes staring at the blank dialog, waiting for Fred to display the next dialog and in the end decided to interrupt it by tapping the Start button. This magically displayed the next dialog's contents with the Start menu on top, making everything alright again.
Right, I've rambled on for long enough. You probably stopped reading hours ago. If anyone has experienced similar problems or have any idea why this might be happening, I would be very grateful to hear from you.
Specs:
Fred is an embedded Visual C++ 3.0 program targetted for Pocket PC 2002, running on an O2 XDA II running Windows Mobile 2003.
Hi,
I have an application which has been running nicely on Harrier and iMate devices, well any PPC devices really because of their rectangular screen shape.
My client has gone and bought some Palm Treo 700wx devices, and they have a smaller square screen.
In the resource of my project the screens are designed to fit PPC. When it runs on the Treo the Treo automatically pops up a scroll bar to allow the whole view to be seen.
The issue is when I first go into the app I can't see the top of the screen, about 20 odd pixels heigh aren't displayed. The scroll bar still displays and I can scroll down to the bottom of the view, and when I scroll up again the top of the screen is still out of sight.
If I exit the app just by tapping on the x in the top right corner (so the app is still running, not exiting properly via my Exit button which shuts down the app), I exit the app and then when I go back into the app the screens are displayed correctly, there is no missing space at the top of the screen.
If I exit the app via my exit button and then start the app again, the top of the view is missing again.
Does anyone know why the screen isn't displayed correctly when I first enter the app, or why it should come right when reloading the view again? Has anyone else had problems with screen layout when putting PPC apps on the square Treo 700wx?
Thanks
It sounds like you have a 'refresh' problem. I haven't encountered this my self and it is really hard to diagnose when you don't even tell us what language your app is written in, but basically here is what I think happens:
When your app is launched, part of its window doesn't get properly painted (not sure why exactly).
When you click the X the app isn't closed, but minimized.
When you return to it the window is maximized and repainted. Second repaint goes correctly.
The quick solution to this would be to force a window refresh just after the app is fully started.
Sorry I forgot to add the language.. it's written in eVC++ 3.0
I'll give the refresh a go, thanks
Further Questions..
I thought that minimising and then maximising the screen fixed the problem, but only partially..
Because the screen in resource is designed for regular PPC it is bigger than the Treo 700 screen size, so the OS automatically shows a scroll bar.
The new issue I'm seeing is to do with the scroll bar. The steps I take to reproduce the issue are:
1. Go to View1, and I scroll down the view (I'm using CView not CDialog)
2. Go to View2
3. Go back to View1. When I go back to the first view the scrollbar is scrolled down in the position I left it.
4. Scroll up to top of view and some of the controls in the wrong place. Some controls I dynamically create in OnInitialUpdate, and as part of the Create() I pass in CRect to tell it where to create the control.
If I set CRect.top to say 10, it's created 10 down from the top of the visible screen. The problem is that because I've scrolled the view previously the view draws it 10 down on the visible portion of the view.
I had thought that the easiest solution would be to always reset the scroll bar to the top of the view before creating my controls, but I'm not sure how to force the OS scroll bar to the top of the view. I've tried SetScrollPos(0,0) or ScrollWindow(0, y). ScrollWindow moves the actual view up or down, but the OS scrollbar is still in the same position.
Any ideas on how to set my view window to the top and to reset the scrollbar?
Thanks again
How to refresh a view?
I have sorted the issue mentioned just above, by finding the scroll position and factoring in that when I set the value of CRect area of the controls I need to dynamically draw.
I'm now just left with the first issue, of when I first start up the app the top part of the window and scrollbar are covered by the Title/Taskbar at the top of the screen.
If I close the app via the x button and restart the app, the issue resolves itself. Or if I open up any dlg like the About screen or even display an AfxMessageBox, when I close the dialog the original screen is redrawn correctly, in the correct position and scroll bar fully shown.
I have tried calling RecalcLayout(), RefreshWindow(), UpdateWindow(), Sending WM_SIZE messages and a whole range of things, but I can't seem to get the screen refreshing correctly apart from when I open any dialog and close that dialog.
When you close a dialog what messages get sent to the previous view that force it to redraw? Does anyone have any suggestions how I can force a refresh myself?
Thanks again
Did you try InvalidateRect?
I am getting a bit rusty with MFC, since I now try to do things the hard way and use pure win 32, but this should work.
If you can't use it as a class member, call the API directly using you view GetSafeHwnd() function for window handle). Use NULL for lpRect to redraw the whole window and FALSE for bErase to prevent flickering.
Note that UpdateWindow() only triggers repaint if part of the window becomes invalid (the contents needs redrawing).
No I hadn't thought of using InvalidateRect(), so I should give it a go.
In the end I just wanted the issue fixed so opted for a quick 'n dirty solution of displaying a temp CDialog as soon as the app starts and calling EndDialog() immediately in the OnInitDialog() so the dialog disappears before you see it.
It worked and the original screen gets updated to correct size, layout and scroll bar.
Cheers.
Ok, so I have been struggling for a couple days with this, and I hope someone can help me.
I want Android to always run my splash screen activity, because I load a bunch of data from web services that I need throughout the rest of the app. This works fine with the flag android:clearTaskOnLaunch="true" set when you launch the app from the home screen.
Where it does not work so well is the long press of the home button and then selecting the app. In that case it starts the app in whatever random spot the user left it last. The problem is that if the app has been killed due to memory, it still shows in that recent apps list and when a user restarts the activity from the long press, all my data is gone so the app force closes.
So, my ugly workaround is to remove the app from the recently run list. I would much rather it showed up there but that it started my app the same way as if it was clicked on the home screen.
Anybody know how to do this? The ebay app pretty much does this, so I know it can be done.
-frank
Instead of reading your data in OnCreate, you could do it in OnResume. See the flow chart here:
http://developer.android.com/reference/android/app/Activity.html
as you can see, OnResume is always called whether the app is created initially, resumed from pause, or reloaded.
kaediil said:
Ok, so I have been struggling for a couple days with this, and I hope someone can help me.
I want Android to always run my splash screen activity, because I load a bunch of data from web services that I need throughout the rest of the app. This works fine with the flag android:clearTaskOnLaunch="true" set when you launch the app from the home screen.
Where it does not work so well is the long press of the home button and then selecting the app. In that case it starts the app in whatever random spot the user left it last. The problem is that if the app has been killed due to memory, it still shows in that recent apps list and when a user restarts the activity from the long press, all my data is gone so the app force closes.
So, my ugly workaround is to remove the app from the recently run list. I would much rather it showed up there but that it started my app the same way as if it was clicked on the home screen.
Anybody know how to do this? The ebay app pretty much does this, so I know it can be done.
-frank
Click to expand...
Click to collapse
In the onResume for the activity that is crashing, you could test your data to see if it's still there, if it's null you can run the code to repopulate it again.
Hi!
I've found a strange Activity behavior while programming a game for Android (currently with API level 8)
Following Situation:
The Main Activity only consinsts of one View on which the Game Thread draws all the sprites and stuff. In the manifest I checked android:multiprocess="false" and android:launchMode="singleInstance" for the Main Activity, so that Android only creates one instance of this activity, so you always come back to your left game after pressing the home button and starting the app again. This works great, but if I turn off the screen WHILE in game, and the activity is active, and turning it back on, Android creates another instance of the game (the Main Activity), so it starts over again.
So my question is, what could I do to prevent this and have the same behavior as if switched back to Home Screen before turning off the screen?
(The testing device is a HTC Desire HD with Android Revolution HD 5.1.7, if this is necessary information for helpers )
I hope someone here can help me!
I think you will have to listen for the screen off intent and handle this situation very explicitly. Maybe make the pause screen come up and then when it turns back on have your activity check for instances of itself and then deal with it.
Do you use static activities?
From something awesome
Thanks for your answer
The ScreenOff/On Intents method would be easy, but how can I recover the old Activity in the new one?
The Activity should be static, cause of the manifest properties, or not?
Another idea: In the onPause() Method queck if it was Screen off (with the corresponding intent) and 'call' the home button
Is this possible? And how could I realize this?
There is a way to use adb to send the home key press. And you can run adb on the phone with getRuntime().exec("adb keyevent xx")
Where xx is the home button constant
From something awesome
Thanks for your help!
But I made it now a much easier way...
One single 'moveTaskToBack()' in the onPause and everything works perfect!
Nice. Its always best to assume that android will do nothing to manage your app and to just do everything very explicitly
From something awesome
This is a bit hard to explain. Bear with me.
On my Z300M, occasionally the screen starts flashing shortly a screen image from another app. It looks as if the app made a screenshot and that this screenshot is repeatedly shown, even though the app is no longer active.
For example, I've been looking to a television program using the (dutch) NPO Start app. I terminate the app and go to the home screen. Suddenly
a screenshot from the NPO app is shown, disappears after a second, reappears after a short while (10-20 seconds) etc. When the screenshot is shown the display is still sensitive to the buttons and icons of the home screen so it is clearly a video problem.
Only a reboot solves it.
Anyone any ideas what could be going on?