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
Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel
Accepted Solution

Need to know about Background application

[ Edited ]

Testing it on simulator having JDE version 5.0. I am working on Alarm Application. So i have created a background Application, where i look into database and perform the task needed just vibrating the phone . I have an alternate point having nongui param. Its works fine . Now the Problem is, i have set an alarm for a time , The time came and the alarm got triggered, and the user has snoozed it for 10 minutes , mean while i just again run my app from the eclipse menu without closing the simulator ,i was expecting that the alarm which was snoozed should get fired but it won't. the problem always occur when i run the app without closing the simulator. So what can be the reason for this, and if i just closed simulator and run it from the eclipse menu its again working fine means the when snoozed times comes it vibrating the simulator can any one explain it to me what are the problem here. Smiley Sad   

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Need to know about Background application

I'm sorry to say I don't think this is enough detail to help.

 

But my take on the problem is that it will be in your code somewhere and you need to debug your code (step through it) and see what it is not doing that you expect it to do and vice-versa....

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Need to know about Background application

But the thing if i close simulator and run it again its working i am facing the problem only if i dont close my simulator and running the app from eclipse.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Need to know about Background application

OK, so by restarting the Simulator you are going through the startup processing again.  I suspect your problem is somewhere in there, or rather in the fact that you don't go through this processing unless you restart the Simulator.  But I have no idea what it is, and as I said earlier, you should be able to investigate this yourself. 

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Need to know about Background application

[ Edited ]

Thanks for the reply one thing i want to know that should i check the SDCard is present or not from the background application. And there is one another problem if i mount the sdcard in the simulator and running the app it's not getting recognised for that i have to run the application two time. So can you tell me how to check for the SDCard present or not for that my code is

public class SDCardTest {

public static boolean SdcardAvailability(){
boolean sdCardPresent = false;
String root = null;
Enumeration e = FileSystemRegistry.listRoots();

while (e.hasMoreElements())
{
root = (String)e.nextElement();
if(root.equalsIgnoreCase("sdcard/"))
{
sdCardPresent = true;
}
}
return sdCardPresent;
}


}
//And its implemetation is like 

public class StopSnoozeApplication extends UiApplication {//implements SystemListener{
	static SqlManager sqlManager;
	public StopSnoozeApplication()  {
		
		boolean SdCardPresent;
		SdCardPresent = SDCardTest.SdcardAvailability();
			if(SdCardPresent){			
				sqlManager = new SqlManager();
				StopSnoozeScreen screen = new StopSnoozeScreen();
	        	pushScreen(screen);
				
			}else{
				 UiApplication.getUiApplication().invokeLater(new Runnable()
		            {
		                public void run()
		                {
		                	
		                    Dialog.alert("This application requires an SD card to be present. Exiting application...");
		                    System.exit(0); 
		                    
		                } 
		            });      
			}
		
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub	
		if( args.length>0&&"alternate".equals(args[0])){
			//Doing Background specific things ........
		}
 		//Doing Gui specific things ..........	
	}

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Need to know about Background application

Not clear here either sorry.....

 

Your code looks fine. 

 

You may be executing this code too early.  You  probably need to wait for the device to be fully up before you check this:

 

http://supportforums.blackberry.com/t5/Java-Development/Write-safe-initialization-code/ta-p/444795

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Need to know about Background application

[ Edited ]

yes i have solved it. You were right peter. I was executing this code too early. That link has helped me to solve the issue. I  want to know one thing that will this background application always runs if my phone is switchoff. please tell