Search Results

Search found 1 results on 1 pages for 'jsc123'.

Page 1/1 | 1 

  • AlarmManager Calling Function in Same Class

    - by jsc123
    I am trying to give a LocationClient a two-minute period to connect before calling getLastLocation on it. Initially I implemented this with a Timer (and TimerTask), but because Timers do not work in sleepmode, I would like to translate it to an AlarmManager. However, I am a bit confused as to how to do this, considering an AlarmManager calls another class, whereas I want to remain in the same class and simply delay for a two-minute period. This is how it looks with a Timer. Timer theTimer = new Timer(); theTimer.schedule(new TimerTask() { @Override public void run() { if(checkIfGooglePlay() && checkTime()) { getPostLocation(); stopSelf(); mLocationClient.disconnect(); } } }, TWO_MINUTES);

    Read the article

1