02-10-2011 04:31 PM
Hi, I don't know why but when my app requests background while the device is locked, it does not get processed.
Did anybody else notice this problem?
Solved! Go to Solution.
02-10-2011 04:43 PM
I think if your device is locked then your app is already in the background, since the locked screen has taken the foreground. Requesting a background while your application is already in the background does nothing (as per the API).
02-10-2011 04:47 PM
Thanks for your help!
Here is the situation that I repeatedly run into:
I launch my app, lock the screen then while locked, I programmed to request background after set amount of time (programmed). Once I unlock the device, the app is still in the foreground.
Normally, if I don't lock, the app would automatically goto background after set amount of time (programmed)
The code I use is:
I don't know whether this becomes invalid when the screen is in locked state.
02-10-2011 05:40 PM
You may try adding a listener to your app that when the system is locking tells your app to go to the background immediately. Why are you wanting your app to background itself though? It could get irritating for a user who wants to get back to where they were.
02-10-2011 08:22 PM
Oh actually, I am starting the app programmatically and pushing dialog and the MainScreen should be in the background while it pushes the dialog. So the app starts while in locked state and pushes mainscreen to the background while pushing the global dialog to the front.
When the user unlocks the device, the only dialog should be present but the mainscreen is shown as well.
02-10-2011 08:45 PM
I believe your objective is not to have the mainscreen present while your dialog is in the foreground, In that case you should try deactivating the screen. popScreen() method should help you achieve that.
02-10-2011 09:37 PM
I've tried the code and get this error: "Uncaught exception: removeScreen: Screen must not be null."
If I pop the mainscreen, wouldn't the global popup dialog pushed fail to push if the mainscreen pops?
02-16-2011 01:38 PM
Okay, I'm trying to implement a workaround. So the app will detect whether the screen is locked. If locked, it will start unlocking by input injection. Once unlocked I would like to push a dialog (while requesting background for main UI).
When i do this, it seems that the dialog is pushed onto the screen before the input injection finishes. So I've added Thread.sleep(2000) - assuming it takes less than 2 seconds to unlock using input injection - but still the UI fails the request background.
I'm quite sure that I'm using the Thread.sleep() in a wrong place. Could someone help me? Where should I insert the Thread.sleep() so that the UI is on hold for 2 seconds while unlocking happens?
02-16-2011 02:09 PM
Is the phone even unlocked after you try to unlock it and the dialog pops up. How are you sending a key injection to unlock it, is it just an oridinary event injection or is it in a thread of its own?I think you need to make sure that your key injections actually unlock the phone before you process the dialog box pop-up.
Btw how do you plan to workaround password locked devices?
02-16-2011 02:17 PM
Oops sorry for not being clear, I meant to say password unlock. The device indeed "password" unlocks using ordinaryevent injection.
I can successfully password unlock the device and pushing dialog but the main Ui does not get sent to the background. I'm curious since when I push dialog then send the main Ui to the background while the device is not password locked, it does it nicely (only dialog visible) but once the device is in "password" locked state, it produces different result. I'm assuming calling the requestbackground() while device is locked does not get processed.