Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.app.PendingIntent;
- import android.app.Service;
- import android.content.Intent;
- import android.media.MediaPlayer;
- import android.os.IBinder;
- import android.support.v4.app.NotificationCompat;
- public class Player extends Service implements MediaPlayer.OnCompletionListener {
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
- public void onCompletion(MediaPlayer paramMediaPlayer) {}
- public void onCreate()
- {
- super.onCreate();
- PendingIntent localPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
- startForeground(1337, new NotificationCompat.Builder(this)
- .setSmallIcon(R.mipmap.ic_launcher)
- .setContentTitle("My Awesome App")
- .setContentText("Doing some work...")
- .setContentIntent(localPendingIntent).build());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement