Last active
January 10, 2018 10:25
-
-
Save wangerekaharun/79529502114466fe8b3fb63f5624d605 to your computer and use it in GitHub Desktop.
Intent Service class which sends a broadcast after every 15 minutes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BackgroundService extends IntentService { | |
public static final String ACTION="ke.co.appslab.androidbackgroundservices.Receivers.ResponseBroadcastReceiver"; | |
// Must create a default constructor | |
public BackgroundService() { | |
// Used to name the worker thread, important only for debugging. | |
super("backgroundService"); | |
} | |
@Override | |
protected void onHandleIntent(@Nullable Intent intent) { | |
// This describes what will happen when service is triggered | |
Log.i("backgroundService","Service running"); | |
//create a broadcast to send the toast message | |
Intent toastIntent= new Intent(ACTION); | |
toastIntent.putExtra("toastMessage","I'm running after ever 15 minutes"); | |
sendBroadcast(toastIntent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment