views:

59

answers:

2

Hi, I want to launch an android application from a remote server, i can see that in J2ME there is a class called PushRegistry, this class resolve this problem in ME but in android I cant do it.

Thanks in advance

+2  A: 

In Android 2.2 (and later presumably) you can use Cloud to Device Messaging (C2DM) to do this.

If you don't have 2.2 you'll have to poll the server from the device to see if the application should launch. You could do this via a Service but it would probably be better to use the AlarmManager to scheduling the polling. You don't want to poll too often as you'll be using up data and battery and so on.

Dave Webb
Thanks for the answer, my phone have Android 1.5, any solution for this version?.
Ricardo
A: 

A really lightweight way to do this is to use the Java Timer class. The Timer's TimerTask can run every minute or two and do an HTTP Get to check for commands from the server. Once the start command is found, you can build an Intent inside TimerTask and use startActivity or startService to launch your Android app.