alarmmanager - Android BoardcastReceiver waiti for network connection to execute function -
i set repeated alarmmanager send pendingintent on time call boardcastreceiver perform update content of apps. problem how wait network connection establish, execute update module?
for example, alarmmanager trigger boardcastreceiver on every saturday 1pm perform update, if there has no network connection miss update.
i had try in boardcastreceiver:
public void onreceive(final context context,intent intent) { thread thread = new thread() { @override public void run() { try { while(!isconnected(context)) { thread.sleep(1000); log.e("myapp","sleep"); } updater updater = new updater(context); updater.execute(); }catch(exception e) { } } }; thread.start(); } isconnected() work well, when establish connection, updater doesnt execute. common or idea perform auto-update? in advance.
let broadcastreceiver start service
Comments
Post a Comment