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
sergiosaad
Posts: 2
Registered: ‎03-16-2009
My Device: 8310

Auto-run on Startup not work on real device

Gentleman,

 

I've just made a research through out the forum and could not solve my problem.

So please, I have to ask you all to be patient because my programming skills are not that good.

 

when I test within the JDE and the 8310 and 9000 sims this work perfectly, but on a real device it just not start, and I have to do it manually.

 

There is my code, could you tell how I can put this to work?

package com.saad.SD; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.system.*; import net.rim.blackberry.api.phone.*; import javax.microedition.io.*; import javax.microedition.location.*; import java.io.*; import java.lang.*; /** * */ public final class SD extends Application { //private BackGroundThread _thread; private BackGroundThread _thread; //public static SD gps; public static void main(String[] args) { SD gps = new SD(); gps.enterEventDispatcher(); } public SD() { _thread = new BackGroundThread(); // create a new separate thread _thread.start(); // start the thread } /* Thread that will run in the background */ private class BackGroundThread extends Thread { //here I get my code. //a lot of work and it is working properly } /* Stop the thread on exit */ protected void onExit() { _thread.stop(); } }

 

 

I have checked the Auto-run on startup option underApplication Tab for this project.

 

I have read the How to - Detect system availability on startup.

but I can't understand how to put it together with my code. (help on that?)

 

Just don't know what to do anymore.

 

thanks again and see if I get some help.

 

best regards,

 

Sergio Saad

 

Sergio Saad
saad@saad.inf.br
SAAD Group
CEO
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Auto-run on Startup not work on real device

I am confused by this statement:

"but on a real device it just not start, and I have to do it manually."

 

How can you start this processing manually - it is an Application, not a UiApplication, so there is no icon to start it?

 

Anyway, there are two common reasons for things not working on the device after working in the JDE/Sim

a) Levels are incorrect.  Remember the JDE Level must be less than or equal to the level on the device

b) Code not signed.  When you compile it should tell you if you need the code signed to run.  Have you signed your code?

New Developer
sergiosaad
Posts: 2
Registered: ‎03-16-2009
My Device: 8310

Re: Auto-run on Startup not work on real device

Hi Peter,

First of all, it's nice to see you here answering, it's an honor.

 

answering your questions:

 


peter_strange wrote:

I am confused by this statement:

"but on a real device it just not start, and I have to do it manually."

 

How can you start this processing manually - it is an Application, not a UiApplication, so there is no icon to start it?




I DO check the Auto-run on startup but for test purposes I DO NOT check the System module, so I can start the app clicking on it's icon. When I get the app running on start up as it should, I'll hide it checking the Systme module option.

 


a) Levels are incorrect. Remember the JDE Level must be less than or equal to the level on the device

 


a) This is the part where probably I'm getting the error: If I got you right, I have set the startup tier as 6, but I have tested with 7 (Last; 3rd party apps only). I really don't know if it is what you mean. this option is under Application Tab of my app Properties.

 


b) Code not signed. When you compile it should tell you if you need the code signed to run. Have you signed your code?


 

b) I have signed my code, so I can use the software on a real device.

 

best regards and thanks for your time

 

Sergio Saad

Sergio Saad
saad@saad.inf.br
SAAD Group
CEO
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Auto-run on Startup not work on real device

Given this information, I agree with what you first propose, i.e. there is a problem in your code in that it runs something before it should at startup time.

 

The KB article you originally linked is in my opinion, the best way to stall your application until startup has completed, however because of the way you have structured your application, you can use an alternative method.  it is used in the following KB article:

 

How To - Display a GUI when the BlackBerry device starts up
Article Number: DB-00539
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To_...

What you need to do is add code like the following at the start of your Thread:

 

ApplicationManager myApp = ApplicationManager.getApplicationManager();
    while(myApp.inStartup()) {
        try {
             _thread.sleep(2000);
        } catch(Exception e) {
             // Catch Exception
        }
    }

This will stall you Thread until it is OK to start up.

 

Let me know how this goes.