android - AlarmManager Call Method Within Class -


i use alarmmanager call specific method within class being called periodically alarmmanager. effectively, use alarmmanager rather timer, because timer's delay ignored when phone not in active use. so, instead of having timer this...

timer thetimer = new timer();     thetimer.schedule(new timertask() {         @override         public void run() {             if(checkifgoogleplay()) {                 getpostlocation();                 stopself();                  mlocationclient.disconnect();             }         }     }, two_minutes); 

i alarmmanager similarly. appears have call class periodically instead of letting me set timer-like function within same class. important within same class, in case, because giving locationclient 2 minutes connect.

thanks help!

i'm not sure why need give locationclient 2 minutes connect. shouldn't take long. in addition, calling locationclient.connect() synchronous, comes immediately. if connection fails because of problem, method onconnectionfailed() called. there should no need wait.

it might if explained you're trying location detection. might able give different strategy pursue. when change approach, becomes more simple.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -