Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Android code snippet - using IntentService
public void onClick(View v) {
startService(new Intent(this, MyService.class));
public class MyService extends IntentService {
private Context mContext;
private Handler mHandler;
public MyService(String name) {
// call from startService()
public MyService() {
mHandler = new Handler();
protected void onHandleIntent(Intent intent) {
mContext = getApplicationContext(); Runnable(){
public void run() {
Toast.makeText(mContext, "Toast Message from IntentService", Toast.LENGTH_LONG).show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.