Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 652
Registered: ‎10-08-2009
My Device: Bold 9900
Accepted Solution

requestbackground locked state

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?

----------------------------------------------------------
Twitter: @gyubok
Regular Contributor
Posts: 64
Registered: ‎01-27-2011
My Device: Not Specified

Re: requestbackground locked state

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).

Developer
Posts: 652
Registered: ‎10-08-2009
My Device: Bold 9900

Re: requestbackground locked state

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:

 

 

UiApplication.getUiApplication().requestBackground();

 

 

I don't know whether this becomes invalid when the screen is in locked state.

 

Thanks

----------------------------------------------------------
Twitter: @gyubok
Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: requestbackground locked state

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.

Developer
Posts: 652
Registered: ‎10-08-2009
My Device: Bold 9900

Re: requestbackground locked state

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.

----------------------------------------------------------
Twitter: @gyubok
Regular Contributor
Posts: 64
Registered: ‎01-27-2011
My Device: Not Specified

Re: requestbackground locked state

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.

Developer
Posts: 652
Registered: ‎10-08-2009
My Device: Bold 9900

Re: requestbackground locked state

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? 

----------------------------------------------------------
Twitter: @gyubok
Developer
Posts: 652
Registered: ‎10-08-2009
My Device: Bold 9900

Re: requestbackground locked state

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?

 

Thanks!

----------------------------------------------------------
Twitter: @gyubok
Regular Contributor
Posts: 64
Registered: ‎01-27-2011
My Device: Not Specified

Re: requestbackground locked state

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? :smileyhappy:

Developer
Posts: 652
Registered: ‎10-08-2009
My Device: Bold 9900

Re: requestbackground locked state

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.

 

Thanks!

----------------------------------------------------------
Twitter: @gyubok