Question

So this is the problem:

The activity starts - and in onResume() does some work in a background thread which populates a listview. This is being done whilst a progress dialog is shown as per the following images:

Loading dialog whilst web services called in background

That work completes - and the progress dialog is told to .dismiss();

The dialog disappears - my listview can be seen , however the activity looses focus - and sort of dims into the background. This forces me to press home, and force close before reopening - as per this example:

The app locks after calling dismiss on the progress dialog

This problem happens EVERY single time the application runs for the first time. Runs after the app locks are always successful and the problem is never evident again! As you can see in the picture - everything has been darkened - however after force closing, reopning the view responds as I would expect with everything working as normal. There is nothing in the logcat to help me diagnose the problem - and all code appears to function correctly.

Please help!

A code dump from the Replay List activity section is here : http://pastebin.com/YG59VFPu - it will probably be tough to follow - but on first run it will do a dropbox login, which works - then it will do findAllReplays() - which also works - eventually ending up in returnres runnable which results in the dialog being dismissed - which also works - which is where the issue seems to happen...

Was it helpful?

Solution

Ok So eventually I did the following.

I created an AsyncTask - which on pre execute created the dialog in the same way, on the end of doinbackground it closed the dialog because my onPostExecute never executes - however dismissing the dialog at the end of doinbackground works. And so that is what I am using, which has essentially solved my problem.

OTHER TIPS

To keep your screen on you can set a flag in your activity

 this.getWindow().
        addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

It will keep your screen on until current activity is in foreground.Or you can use wake lock if you are doing some thing in background and want to keep your screen on before ,during or after background work.

Power Manager to keep screen on.Never forget to mention appropriate permission.

Although you solve your problem before my answer but hope it help you to clear concept to keep screen on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top