BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 10-30-2007, 09:32 PM   #1
siqiabc
New Member
 
Join Date: Oct 2007
Location: xi'an , China
Model: 7100t
PIN: N/A
Carrier: 710067
Posts: 12
Smile How to run my application in background?

Please Login to Remove!

How to run my application in background?
Offline  
Old 10-30-2007, 10:09 PM   #2
streamh
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8800
PIN: N/A
Carrier: GPRS
Posts: 68
Default

Code:
/*
 * guiLessApplication.java
 *
 * ?<your company here>, 2003-2005
 * Confidential and proprietary.
 */

package GUILessApp;

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.*; 

public final class GUILessApp extends Application
{ 
     private BackGroundApp backGroundApp; 
     public static void main(String[] args) 
     { 
          GUILessApp theApp = new GUILessApp();
          theApp.enterEventDispatcher(); 
     }

     public GUILessApp()
     {
          //Creates and starts a new BackGroundApp thread.         

          backGroundApp = new BackGroundApp();
          backGroundApp.start();
     }

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

          public void run() 
          {
               int n = 0;
               while (!stopThread) 
               { 
                    //You would perform your processing here.
                    //This sample just prints out a line 
                    //to the BlackBerry JDE Output Window
                    
                    System.out.println("Application is running" + n + "th times!");
                    n++; 

                    //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() 
     { 
          backGroundApp.stop(); 
     } 
}
Offline  
Old 10-31-2007, 01:29 AM   #3
siqiabc
New Member
 
Join Date: Oct 2007
Location: xi'an , China
Model: 7100t
PIN: N/A
Carrier: 710067
Posts: 12
Default

thank you!
Offline  
Old 10-31-2007, 05:17 AM   #4
genvej
Thumbs Must Hurt
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: TDC
Posts: 115
Default

Another way to do it is to edit the properties of your project and simply tick

system module

auto-run on startup
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


10 PCS 1K,2 K,5K,10K,20K100K,1Mohm Linear Taper Rotary Potentiometer US Stock picture

10 PCS 1K,2 K,5K,10K,20K100K,1Mohm Linear Taper Rotary Potentiometer US Stock

$9.49



10 turn Potentiometer 3590S Wirewound Variable Resistor Precision multi-turn POT picture

10 turn Potentiometer 3590S Wirewound Variable Resistor Precision multi-turn POT

$51.49



Clarostat RA20LASD103A 10K OHM Wirewound 10000 Ohm Potentiometer Industrial POT picture

Clarostat RA20LASD103A 10K OHM Wirewound 10000 Ohm Potentiometer Industrial POT

$14.19



US Stock 10 Units 100K B100K OHM Linear Taper Rotary Potentiometer POT Red Knob picture

US Stock 10 Units 100K B100K OHM Linear Taper Rotary Potentiometer POT Red Knob

$9.49



Digital Display Potentiometer  Variable Resistor 5K 10K 20K 50K 100K DC 6-30V picture

Digital Display Potentiometer Variable Resistor 5K 10K 20K 50K 100K DC 6-30V

$9.15



10K Ohm Rotary Potentiometer Variable Dial Resistor Precision 10-Multiturn Blue picture

10K Ohm Rotary Potentiometer Variable Dial Resistor Precision 10-Multiturn Blue

$7.95







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