SHARE
TWEET

Untitled

a guest Jul 16th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top