Skip to content

Instantly share code, notes, and snippets.

@moea
Created October 28, 2014 13:39
Show Gist options
  • Save moea/2537eb68fe3db174e5be to your computer and use it in GitHub Desktop.
Save moea/2537eb68fe3db174e5be to your computer and use it in GitHub Desktop.
package me.ambient.cachehours;
import android.app.IntentService;
import android.content.Intent;
import android.content.Context;
import android.support.v4.content.LocalBroadcastManager;
public class MyIntentService extends IntentService {
public MyIntentService() {
super("MyIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
if (intent != null && "do the doge".equals(intent.getAction())) {
doTheDoge();
}
}
protected void doTheDoge() {
// do the doge for a while
try {
Thread.sleep(15 * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent("did the doge"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment