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
jd15
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified
Accepted Solution

alt entry basic ...

Ok i've read 100 threads on alteranate entry points and all the KBs and tutorials.  they all seem to do things a little differently, which may be confusing me.   To simplify im trying with just the most basic setup, as shown below.  I just want to be able to have an alternate entry point that will work with the running application's gui. the first run works fine, and shows the screen. on the second run (from the 2nd icon), im able to retrieve the app from the store, and its show as alive.  but when i run loadScreen which pushes a screen (and i've tried it dozen differnet ways), it throws illegalstatexception on application.getapplication().

i figure if i can just get the most basic example working i could work it into my existing app ... but i cant even get the basic version working. im sure im missing some very fundamental issue here ...

 

 

	public static void main(String[] args) {
		
		RuntimeStore appReg = RuntimeStore.getRuntimeStore();		
		AltEntry theApp;
		
		synchronized(appReg) {
			theApp = (AltEntry)appReg.get(ID);			
		}
		
		if (theApp == null) {
			theApp = new AltEntry();
			appReg.put(ID, theApp);
			theApp.enterEventDispatcher();
		}
		else {
			theApp = (AltEntry)appReg.waitFor(ID);
			theApp.requestForeground();
            theApp.loadScreen();
			
		}
			
    }

	
	AltEntry() {		
		MainScreen s = new MainScreen() {
			
			public boolean onClose() {
				UiApplication.getUiApplication().requestBackground();
				return false;
			}
		};
		
		s.setTitle("this is the main screen");
		UiApplication.getUiApplication().pushScreen(s);
			
	}
	
	public void loadScreen() {
		final MainScreen s1 = new MainScreen();
		s1.setTitle("from loadScreen");
 
		UiApplication.getUiApplication().invokeLater(new Runnable() {
			public void run() {
				
				UiApplication.getUiApplication().pushScreen(s1);
			}
		});

	}
	

 

 

 

 

 

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

Re: alt entry basic ...

[ Edited ]

I agree with this statement "100 threads on alternate entry points and all the KBs and tutorials.  they all seem to do things a little differently".

 

And I think 1./2 of them do it badly.  I think the KB articles all do it correctly, but they do different things in slightly different ways and people try to do them all together, which doesn't work.

 

There are two simple use cases for Alternate Entries, where they work perfectly.

 

1) Where is a small amount of start processing that needs to be done at startup, but you do not need an Application running to do this.  The classic here is the setting of the icon and rollover icon.  In this situation you have a main that has code like this:

if (arg is autotstart) {

// set icons

} else {

create new app and enter dispatcher

}

 

2) You want two icons that use the same 'application code' but perform slightly different processing.  The solution to this Thread shows a working example of this use case:

http://supportforums.blackberry.com/t5/Java-Development/Multiple-running-instances-of-the-same-entry...

 

I would review some of my other posts on that Thread for further explanations of what goes on (as I understand it).

 

Now having talked about this, can you explain again what you are trying to do here.  Having two icons but the one application, which is what I understand you to be trying to do, does not seem a useful why to use an Alternate Entry.  So I'm not sure we want to spend a lot of time figuring out how to do this.

 

But why don't you try replacing

theApp.loadScreen();

with

theApp.invokeLater(new Runnable() {
public void run() {

theApp.loadScreen();

}

});

 

Please use plain text.
Developer
jd15
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: alt entry basic ...

my ultimate goal is -- i have an existing gui app thats something of a database frontend, with information about clients and the ability to perform a variety of actions on the clients and their various associated objects. it communicates with a web site to get the data and perform the actions, although i dont think thats relevant for this.  what i want to do is to have a FolderListner or to add a general menutiem to messages, so that when an email arrives from someone who is in my database, i can go directly to their screen/page in my app.  So my understanding is, in order to get the screen/page associated with that user, i would need to call my app w/an alternate entry that tells is to push the user's screen.

Please use plain text.
Developer
jd15
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: alt entry basic ...

that fix worked. i spent so long trying 1000 things today, unbelievable ... thanks :smileyhappy:

although maybe from my other post ... not sure if this is still the right way to do what im trying to do?

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

Re: alt entry basic ...

[ Edited ]

Not sure I would do it that way.

 

When the email arrives, you can pick it up with the FolderListener.  Then you can send the details to your application using a GlobalEvent.  Your application can then foreground itself and display a screen associated with that user, pretty much like your alternate entry, but driven by the GlobalEvent Listener.  Would that work for you?

 

 

Please use plain text.
Developer
jd15
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: alt entry basic ...

that sounds like an infinitely better/easier idea.

ill give that a try. thank you.  would that need  this.invokelater in eventoccurred since its in the background?

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

Re: alt entry basic ...

Probably too late, but here is a good KB article:

 

What Is - Global Events and Global Event Listeners
Article Number: DB-00145
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/What_Is...

 

Re your other question, yes, however since you will be executing in a Thread that is owned by your Application, you will be able to use

UiApplication.getUiApplication().invokeLater().

 

With this approach, you should not need an Alternate Entry and you should not need to put your app in RuntimeStore.

Please use plain text.
Developer
jd15
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: alt entry basic ...

looks like its working exactly as i was hoping (for this part anyway :smileyhappy:). Thank you!

Please use plain text.