Android, launch an app from remote server

一笑奈何 提交于 2019-12-23 12:02:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!