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: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: listening to incoming SMS not working

may the 2nd option which u said making another application and add alternate entry point will do.Can u please help me with how to add the alternate entry point and what i need to do basically to make changes to main method.

Highlighted
Developer
Posts: 543
Registered: ‎12-23-2010
My Device: Z10
My Carrier: Airtel

Re: listening to incoming SMS not working

[ Edited ]

I dont think requesting the App to background is the good solution.

 

The better thing is create An app which extends Application and start that app in device start up(you can do this by selecting auto start up), also select dont show icon.

 

You can do this by creating Alternative entry point in Alternative entry point.

 

suppose if you want create an alternative point named "gui"

these are the steps.

 

1. Open the Appdescriptor.xml->select AlternateEntry points tab.

2.now click on add.

3.now give the title = "gui"

4. Application arguement = "gui"

5. select autorun startup and donot display the icon.

 

 

 

Now your main method will be like.

 

public static void main(String[] args) 
	{
		 if(args != null && args.length >0)
	     {
		     if(args[0].equalsIgnoreCase("gui"))
		     {
		    	 BackgroundThread appThread = new BackgroundThread();
		    	 appThread.startBackgroundThread();
		    	 appThread.enterEventDispatcher();
		     }
	     }
	     else
	     {
	    	 YourAppName theApp = new YourApp();
	    	 theApp.enterEventDispatcher();
	     }
	}

 

And now your background thread will be

 

public class BackgroundThread extends Application
{
	private boolean running;
public void startBackgroundThread()
    {
		running = true;
        new Thread()
        {
         public void run() 
         {
while (running)
            {
//your code to listen sms and alert
}
}.start();
}
}

 

Thanks.