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
Posts: 7
Registered: ‎11-24-2008
My Device: Not Specified

two instances

I am writing an application to open a word document from a remote server using the content handler apis .In my application,whenever i try accessing any file,another instance of my application is created.The second instance works properly,without creating any instances.
In my main method,I have a static reference of my uiappliaction,which seems to return as null when my application runs for the first time,but it seems to work with the second instance which gets created.

if(DocumentViewer.docViewer==null){ docViewer = new DocumentViewer(); docViewer.enterEventDispatcher(); }

 

I tried RuntimeStore but it does not work.Can some one tell me how to avoid having two instances.
   
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: two instances

Please have a look at this sample.

 

How to - Create a singleton using the RuntimeStore
Article Number: DB-00686

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/832062/How_to_...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 7
Registered: ‎11-24-2008
My Device: Not Specified

Re: two instances

Thanks for the reply! I had tried that before,but my application does not work with that.If i invoke my application from some other application then my application works properly without creating any instances.

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: two instances

I'm not sure I understand the problem you are seeing.  Can you describe it further and provide the steps you are taking to reproduce the problem?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 7
Registered: ‎11-24-2008
My Device: Not Specified

Re: two instances

I am writing an application to read word documents from the server.I am using jde 4.5.The application is based on the chapidemo sample.

 

Invocation invoc = new Invocation(URL); invoc.setResponseRequired(false); invoc.setAction(ContentHandler.ACTION_OPEN); Registry registry = Registry.getRegistry(CLASSNAME); registry.invoke(invoc);

 

After registry.invoke(),the main method is called and my application gets instantiated again.After that there is no problem.If i use the runtime store,one instance is maintained but it does not open the word documents.

 

I tried to launch the same application from a different application using ApplicationManager.getApplicationManager().runApplication().It works properly at that time without creating any instance.

 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: two instances

What happens after you application is invoked via JSR 211?  Does the application exit or remain running in the background or foreground?  Is it still running when you try the second invokation?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 7
Registered: ‎11-24-2008
My Device: Not Specified

Re: two instances

After the invocation,the first instance remains running in the background.The first instance remains in the background even when i work with the second instance.If i exit my second instance then the first instance comes to the foreground.

Highlighted
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: two instances

What is shown in the foreground?  Are you seeing a screen from each instance?  Has your application attempted to close the screen?  If not, it would be expected that the previous screen is shown underneath.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker