BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-09-2008, 10:24 PM   #1 (permalink)
New Member
 
Join Date: Jul 2008
Model: 8330
PIN: N/A
Carrier: Verizon
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy How do I retrieve a background instance from RunTimeStore?

Please Login to Remove!

I am using Eclipse with the latest BlackBerry Plug-in. I have a UI app with an alternate entry point. I want the main instance to load on start-up and run in the background. When the user clicks the alternate entry icon, I want it to bring the already running instance to the foreground. I am using the RunTimeStore to try and achieve this, but I can't get it to work. Here's the code from my main application class:

Code:
package com.mydomain.blackberry.myapp;

import net.rim.device.api.system.*;

public class MyApp extends net.rim.device.api.ui.UiApplication
{
	private static final long APP_ID = 0xc4ad1aa047b610f6L;
	
	public static void main(String[] args)
	{
		RuntimeStore runtimeStore = RuntimeStore.getRuntimeStore();
		if (args != null && args.length > 0 && args[0].equals("gui"))
		{
			synchronized(runtimeStore)
			{
				MyApp myApp = (MyApp)runtimeStore.get(APP_ID);
				if (myApp != null)
				{
					myApp.requestForeground();
				}
				else
				{
					runtimeStore.put(APP_ID, new MyApp());
				}
			}
		}
		else
		{
			synchronized(runtimeStore)
			{
				runtimeStore.put(APP_ID, new MyApp());
			}
		}
	}
	
	public MyApp()
	{
		this.pushScreen(new LaunchScreen());
		this.enterEventDispatcher();
	}
}
Also, when I step-through the code, it will not step passed the runtimeStore.get(APP_ID) line. It just keeps trying to execute that line of code. I step over it, it acts like it's thinking, then comes right back to it. I can't get passed that line of code.

My LaunchScreen class simply extends MainScreen and has some basic fields on it. I've been wrestling with this for days! What am I doing wrong? Please help!??
Offline  
Old 07-10-2008, 03:27 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

i would suggest that you work with globaleventlistener, have your app running in the background and get it to foreground when you receive the event.
as long as you have your pushscreen in the constructor you will not be able to create an instance without displaying the screen.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 07-10-2008, 08:45 AM   #3 (permalink)
New Member
 
Join Date: Jul 2008
Model: 8330
PIN: N/A
Carrier: Verizon
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the response, but I don't think that's the problem here. I would be *happy* for my screen to show-up. The problem right now is that I can't seem to retrieve the app instance from the RunTimeStore. When stepping through code I can't get passed the call to get my object from the store. It just gets stuck there. My app is there in the background, and I can use the ribbon to switch to it and bring it to the foreground. That works fine, but using the alternate entry to bring it to the foreground doesn't. It doesn't do anything.

Any other ideas?
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.