How to add button to notifications in android?

前端 未结 8 1464
孤独总比滥情好
孤独总比滥情好 2020-12-05 03:53

My app plays music and when users open notifications screen by swiping from the top of the screen ( or generally from the bottom right of the screen on tablets ), I want to

8条回答
  •  时光说笑
    2020-12-05 04:19

        // It shows buttons on lock screen (notification).
    
    Notification notification = new Notification.Builder(context)
        .setVisibility(Notification.VISIBILITY_PUBLIC)
        .setSmallIcon(R.drawable.NotIcon)
        .addAction(R.drawable.ic_prev, "button1",ButtonOneScreen) 
        .addAction(R.drawable.ic_pause, "button2", ButtonTwoScreen)  
       .....
        .setStyle(new Notification.MediaStyle()
        .setShowActionsInCompactView(1)
        .setMediaSession(mMediaSession.getSessionToken())
        .setContentTitle("your choice")
        .setContentText("Again your choice")
        .setLargeIcon(buttonIcon)
        .build();
    

    Please refer this for more details Click here

提交回复
热议问题