问题
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
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/3397286/android-launch-an-app-from-remote-server