Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. package com.example.suvajit.servicedemo;
  2.  
  3. import android.app.Service;
  4. import android.content.Intent;
  5. import android.os.IBinder;
  6. import android.support.annotation.Nullable;
  7. import android.widget.Toast;
  8.  
  9. public class BackgroundService extends Service {
  10. @Nullable
  11. @Override
  12. public IBinder onBind(Intent intent) {
  13. return null;
  14. }
  15.  
  16. @Override
  17. public int onStartCommand(Intent intent, int flags, int startId) {
  18. Toast.makeText(BackgroundService.this, "Service Started...", Toast.LENGTH_SHORT).show();
  19. return START_STICKY;
  20. }
  21.  
  22. @Override
  23. public void onDestroy() {
  24.  
  25. // Removed the restart service from onDestroy
  26.  
  27. Toast.makeText(BackgroundService.this, "Service is Stopping...", Toast.LENGTH_SHORT).show();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement