Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import android.app.PendingIntent;
  2. import android.app.Service;
  3. import android.content.Intent;
  4. import android.media.MediaPlayer;
  5. import android.os.IBinder;
  6. import android.support.v4.app.NotificationCompat;
  7.  
  8. public class Player extends Service implements MediaPlayer.OnCompletionListener {
  9. @Override
  10. public IBinder onBind(Intent intent) {
  11. return null;
  12. }
  13.  
  14. public void onCompletion(MediaPlayer paramMediaPlayer) {}
  15.  
  16. public void onCreate()
  17. {
  18. super.onCreate();
  19. PendingIntent localPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
  20. startForeground(1337, new NotificationCompat.Builder(this)
  21. .setSmallIcon(R.mipmap.ic_launcher)
  22. .setContentTitle("My Awesome App")
  23. .setContentText("Doing some work...")
  24. .setContentIntent(localPendingIntent).build());
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement