1. Download our Official Android App: Forums for Android!

Apps pause/play button on notification

Discussion in 'Android Development' started by swapniladsure, Aug 31, 2012.

  1. swapniladsure

    swapniladsure Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Jun 22, 2012

    Jun 22, 2012
    3
    0
    5
    hey guys
    i want to write a code in which notification having one button (pause) and when user press it pause the media play..
    here is my notification code
    please suggest me solution or any sample code for this


    int icon = R.drawable.vmix;
    CharSequence tickerText = "Vmix";
    long when = System.currentTimeMillis();

    Notification notification = new Notification(icon, tickerText, when);

    notification.flags |= Notification.FLAG_ONGOING_EVENT;


    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.noti);
    contentView.setImageViewResource(R.id.image, R.drawable.vmix);


    notification.contentView = contentView;

    Intent notificationIntent = new Intent(this, MainActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    notification.contentIntent = contentIntent;
    final int CUSTOM_VIEW_ID = 1;
    mNotificationManager.notify(CUSTOM_VIEW_ID, notification);
     

    Advertisement

Share This Page

Loading...