BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-08-2007, 08:39 AM   #1 (permalink)
Thumbs Must Hurt
 
Spartan115's Avatar
 
Join Date: Aug 2007
Model: Pearl
PIN: N/A
Carrier: T-Mobile
Posts: 80
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Writing a Background Application that Auto-starts

Please Login to Remove!

How can I write a background app for the Blackberry in Java that auto-starts whenever the phone is turned on? Is there any way to do this? Thanks in advance.
Offline  
Old 09-08-2007, 07:19 PM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: TDC
Posts: 115
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

check auto start in project properties... if you want it as a background process check system module as well
Offline  
Old 09-08-2007, 11:07 PM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Spartan115,

Quote:
Originally Posted by Spartan115 View Post
How can I write a background app for the Blackberry in Java that auto-starts whenever the phone is turned on? Is there any way to do this? Thanks in advance.
The following Background Application sample will run indefinitely until the device is shut down:
Code:
public final class BackGroundApplication extends Application {
	
     private BackGroundAppThread backGroundAppThread;
     
     public static void main(String[] args) {
          BackGroundApplication theApp = new BackGroundApplication();
          theApp.enterEventDispatcher();
     }

     public BackGroundApplication() {
          // Creates and starts a new BackGroundApplication thread.
          backGroundAppThread = new BackGroundAppThread();
          backGroundAppThread.start();
     }

     // The thread that will run in the background.
     private class BackGroundAppThread extends Thread {
     	
          boolean stopThread = false;
          
          public synchronized void stop() {
               stopThread = true;
          }

          public void run() {
          	
               while (!stopThread) {
                    // You would perform your processing here.                    
                    // ...
                    
                    // Sleep for 5 seconds to prevent the
                    // application from running out of control
                    try {
                         sleep(5000);
                    }
                    catch (Exception e) {
                         // Exception handling would go here.
                    }
               }
          }
     }
     
     //Stop the thread on exit.
     protected void onExit() {
          backGroundAppThread.stop();
     }
}
Hope This will Help!

Cheers,
ARIF

Last edited by arifzaman : 09-08-2007 at 11:13 PM.
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.