BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-19-2007, 05:54 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default How to run an application at a specified time?

Please Login to Remove!

I have an application that have the functionality like this: Auto Sync - the user can choose specified time (ex. 4.00 p.m.) and the application have to run itself at that time and make the synchronization process. How can i start the application at specified time is the main problem. The other possible solution is to run an application with auto-run in the background when the device is started and check if the time is reached. And the last question i have is how can i make an application auto-run through Eclipse?
Offline  
Old 11-19-2007, 11:06 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2005
Location: Portland, OR., USA
Model: 9800
Carrier: AT&T
Posts: 82
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

One solution is to push your application to the background when the user thumbs the escape button using ..
UiApplication.getUiApplication().requestBackground ();

Then use the Timer and TimerTask classes to schedule wakeup and checks.

You can also implement SystemListener on your mainscreen and then implement ...
public void powerOff() { }

public void powerUp() {
//Application.getApplication().requestForeground();
//do start up checking
}

Your app needs to run running (in background) when the device is shutdown in order for the powerUp() to be activated.

HTH,
Eric
Offline  
Old 11-20-2007, 01:50 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, maybe that's an idea. Now I will try to do this functionality with this:
Code:
ApplicationManager.getApplicationManager().scheduleApplication(ApplicationDescriptor.currentApplicationDescriptor(), System.currentTimeMillis() + 180000, true);
Thanks !
Offline  
Old 08-14-2008, 03:04 AM   #4 (permalink)
New Member
 
praveen@unispeck.com's Avatar
 
Join Date: Jul 2008
Location: Kochin
Model: 8800
PIN: N/A
Carrier: Airtel
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Pleas find below Application. It may help your !!

Code:
import net.rim.blackberry.api.homescreen.HomeScreen;
import net.rim.device.api.system.Application;
import net.rim.device.api.system.Bitmap;

public final class BackGroundApplication extends Application {

	private BackGroundAppThread backGroundAppThread;
	final Bitmap regIcon = Bitmap.getBitmapResource("icon1.png");//Icon1 for interchange
	final Bitmap icon = Bitmap.getBitmapResource("icon2.png");//Icon2 for interchange

	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();//Starting here
	}

	private class BackGroundAppThread extends Thread {

		boolean stopThread = false;

		public synchronized void stop() {
			stopThread = true;
		}

		public void run() {
			int timeOut = 300;//setting the change over time as 300 millis
			while (!stopThread) {//Loop till Stop thread
				HomeScreen.updateIcon(icon, 0);
				System.out.println("");
				try {
					sleep(timeOut);//puting sleep for 300 millis
					HomeScreen.updateIcon(regIcon, 0);//updating old icon with new one
					sleep(timeOut);//puting sleep for 300 millis					
				} catch (Exception e) {
					System.out.println("Exceptio in Sleep" + e);
				}

			}
		}
	}

	protected void onExit() {
		backGroundAppThread.stop();
	}
}
__________________
Praveen K
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.