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
New Developer
ashengjie
Posts: 83
Registered: ‎02-22-2009
My Device: Not Specified

how to pop up a screen form an entry point and background app ?

my app is run in background and have an  entry point , now i  want pop up a screen from background  while i click the icon ,

bellowing are the codes :

 

final class Main extends Application { public static void main(String[] args){ // click the app icon if ( args != null && args.length > 0 && args[0].equals("gui") ){ UiEngine ui = Ui.getUiEngine(); Screen screen = new PopForm( message ); ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE); //run in back ground }else { new Main().enterEventDispatcher(); } } public Main(){ this.addFileSystemListener( new FileController() ); } }

now i found that  when i click the icon,   the app get      "no application instance"      error  

 

use this method  get same error  , how to resloved it ?

 

 

public void popUpScreen(String strMessage){ try { if(strMessage != null && strMessage.length() > 0){ Application.getApplication().invokeLater(new NewRunnable(strMessage) ,200,false); } } catch (Exception e) { // TODO Auto-generated catch block System.out.println( e.toString()); } } public class NewRunnable implements Runnable{ public String message; public NewRunnable(String context){ this.message = context; } public void run(){ UiEngine ui = Ui.getUiEngine(); Screen screen = new PopForm( message ); ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE); } }

 

Please use plain text.
Developer
peter_strange
Posts: 19,602
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to pop up a screen form an entry point and background app ?

Please review the KB article:

 

How To - Setup an alternate entry point for my application
Article Number: DB-00008
 
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800901/How_To_-_Setup...

 

You will note that the enterEventDispatcher() is called on the Foreground startup, not the Background startup.  Try changing your startup to follow the KB article.

 

Warning, the following is personal opinion.

 

I do not like alternate entry points because I think they are misused by the majority of people.  The background processing invoked in the .primary startup' should not actually run anything significant.  Alternate entry is intended to be used when you need to set something up like a listener, or do some initialization.  However most people attempt to do significant processing in it and end up creating two UiApplications, one that gets started in the background, and another that gets started by the icon.  This causes confusion, and some relationship problems, as things like statics are not started between these processes.

 

Instead I recommend that you only have one startup.  Don't use Alternate Entry.  You can even push your screen,  It won't be shown because the device is in startup.  However because you are likely to do screen type processing, you must delay this processing until the Blackberry is good and ready.  So follow the instructions of this KB article. 

 

How to - Detect system availability on startup 
Article Number: DB-00642
 
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800901/How_to_-_Detec...

Please use plain text.
New Developer
ashengjie
Posts: 83
Registered: ‎02-22-2009
My Device: Not Specified

Re: how to pop up a screen form an entry point and background app ?

i think i must used entry point  , because  while i click the icon , i need popup different screen by click the icon,  so i need use entry point , any another suggestion?

Please use plain text.
New Developer
ashengjie
Posts: 83
Registered: ‎02-22-2009
My Device: Not Specified

Re: how to pop up a screen form an entry point and background app ?

did you know another method to catch the action while user click the icon.

Please use plain text.
New Developer
ashengjie
Posts: 83
Registered: ‎02-22-2009
My Device: Not Specified

Re: how to pop up a screen form an entry point and background app ?

how can i  pop up screen from app entry point by click app icon ?  anybody can help me ?

Please use plain text.
Developer
peter_strange
Posts: 19,602
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to pop up a screen form an entry point and background app ?

Sorry, I am not clear on your question.  If it were not possible to pop up a screen when someone clicks on an icon, how many BlackBerry apps would work?  All the sample programs do it.  The alternate entry KB article I pointed you to earlier does it.  How about looking at these and reviewing your code to figure out what is going wrong with your code?

 

If you can't figure it out, can you please give us a more detailed question describing what you see and what you would like to see, and if you think necessary, the associated code snippets.

 

I suggest you use the debugger to trace your code so that you know exactly where it is breaking and the detail of any Exception that is thrown.

Please use plain text.
New Developer
ashengjie
Posts: 83
Registered: ‎02-22-2009
My Device: Not Specified

Re: how to pop up a screen form an entry point and background app ?

as you said , i have two application , one is background app , another is from entry point , now  when i click the app icon , i want pop up one pop screen , but when i use Application.getApplication()  , the programing  show an error "no application instance" ,

it is because  enterEventDispatcher()  is not add in the  forground, but if i add it in the forground, my background app can't popup screen too ,   i think i can't add enterEventDispatcher in both forground and background  ;

Please use plain text.
New Developer
ashengjie
Posts: 83
Registered: ‎02-22-2009
My Device: Not Specified

Re: how to pop up a screen form an entry point and background app ?

i means  my app is a background ground,  but while i click one app icon , i want popup some sreen at that time . my background app will popup screen too in some times.....

Please use plain text.
Developer
peter_strange
Posts: 19,602
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to pop up a screen form an entry point and background app ?

"i think i can't add enterEventDispatcher in both foreground and background".

 

I believe you can, and I have applications that do.  You will have a background application, and a foreground application running from the same cods.

 

So give it a go.

Please use plain text.