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
arunbiet
Posts: 391
Registered: ‎06-22-2010
My Device: na

Re: Showing my own app when i unlock the screen

class LockApp extends Thread {
	public void run() {
		// TODO Auto-generated method stub
		 if(ApplicationManager.getApplicationManager().isSystemLocked())
    	 {
     		UiApplication.getUiApplication().invokeLater(new Runnable() 
     		{	
 				public void run() 
 				{
 					Dialog.alert("LOCK");
 					
 				}
 			}) ;
     	 }
     	 else 
     	 {
	       UiApplication.getUiApplication().pushScreen(new MyScreen());
     		
     	 }
	  
	}

 Now my updated code is the above.And i am calling this from doStartUpWork and doStartUpWorkLater in this manner 

LockApp lck=new LockApp();
		lck.start();

 

Developer
arunbiet
Posts: 391
Registered: ‎06-22-2010
My Device: na

Re: Showing my own app when i unlock the screen

No luck even after putting it in thread and calling from there

Developer
arunbiet
Posts: 391
Registered: ‎06-22-2010
My Device: na

Re: Showing my own app when i unlock the screen

By the way i have made the app as autostartup,hope it is not creating any problem

Developer
arunbiet
Posts: 391
Registered: ‎06-22-2010
My Device: na

Re: Showing my own app when i unlock the screen

I have put debug points to verify the code below 

 public MyApp()
    {     
    	if (ApplicationManager.getApplicationManager().inStartup())
        {
    		addSystemListener(this);
        }
		else
		{
			doStartupWorkLater();	
		}
    }

 So when i execute the app for the first time,that if block doesnt execute and else block executes.Now when i lock the screen and than unlock,the control never returns to the app

Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10

Re: Showing my own app when i unlock the screen

[ Edited ]

Sorry i forgot to tell this, make ur screen to show globally

 

UiApplication.getUiApplication().invokeLater(new Runnable() 
{ public void run() {
MyScreen myScreen = new MyScreen();
if(myScreen == null) Ui.getUiEngine().pushGlobalScreen(myScreen, 1, UiEngine.GLOBAL_MODAL); }
});

 Try This code to show ur screen on top, Hope This will help?

 

Developer
arunbiet
Posts: 391
Registered: ‎06-22-2010
My Device: na

Re: Showing my own app when i unlock the screen

I am using 9860 blackberry.When i run the app,its opening my screen.Now if i click the lock button at top,it gets locked.Now when i again unlock it,the first screen comes as my app screen,which is great.Now as u can see myscreen has a dialogbox wid ok button,where if we click ok button,i am calling close method and the app closes.Now if i again lock the screen and than unlock,my app screen is not showing.My requirement is that even if i close my app,everytime i lock and unlock,that screen shud appear first

Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10

Re: Showing my own app when i unlock the screen

Thats because you are closing your app, make your app request background, using UiApplication.getUiApplication().requestBackground();
this will solve your problem.
Developer
arunbiet
Posts: 391
Registered: ‎06-22-2010
My Device: na

Re: Showing my own app when i unlock the screen

i tried the same as you suggested,but as i am pushing the screen in this way,i mean the dialog screen

 GlobalDialog screen = new GlobalDialog(title, text);

	            ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);

 so may be that code doesnt seem to work,if i request background it isnt closing at all

Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10

Re: Showing my own app when i unlock the screen

UiEngine.GLOBAL_MODAL use this
Developer
arunbiet
Posts: 391
Registered: ‎06-22-2010
My Device: na

Re: Showing my own app when i unlock the screen

same result