1. Are you ready for the Galaxy S20? Here is everything we know so far!

Unable to add action button to notification message

Discussion in 'Android Development' started by AKA001, Feb 10, 2016.

  1. AKA001

    AKA001 Newbie
    Thread Starter

    Hello All,

    I have been trying to add an action button to the notification message, but it is not showing up. Also, any change i am making to customise the notification message is not taking effect for e.g.. set lights, big text etc:



    Intent notificationIntent1 = new Intent( context, null );

    PendingIntent contentIntent1 = PendingIntent.getActivity(context, 0, null, 0);;

    ///


    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder( context );

    notificationBuilder.setSmallIcon(appIcon);

    notificationBuilder.setTicker(tickerText);

    notificationBuilder.setWhen(System.currentTimeMillis());

    notificationBuilder.setContentTitle(contentTitle);

    notificationBuilder.setContentText("testing");

    notificationBuilder.setAutoCancel(true);

    notificationBuilder.setContentIntent(contentIntent);



    notificationBuilder.setStyle(new NotificationCompat.BigTextStyle());

    notificationBuilder.addAction(new NotificationCompat.Action(R.drawable.icon, "futher",contentIntent1));

    // notificationBuilder.addAction(R.drawable.icon,"test", PendingIntent.getActivity(context, 0,notificationIntent1, 0, null) );

    Notification notification = notificationBuilder.build();



    NotificationManager notificationManager = (NotificationManager) context.getSystemService( Context.NOTIFICATION_SERVICE );

    notificationManager.notify( 0, notification );

    Appreciate your assistance in advance
     



    1. Download the Forums for Android™ app!


      Download

       
  2. scary alien

    scary alien not really so scary
    VIP Member

    Welcome to our AndroidForums, @AKA001.

    I've moved your thread over here to our Application Development area for you where you'll get more appropriate views and replies.

    Cheers!
     
Loading...

Share This Page

Loading...