Android notification .addAction deprecated in api 23

后端 未结 4 2123
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 12:45

What is the proper way to add an action to the notification in API 23 since addAction(int icon, CharSequence title, PendingIntent intent) is deprec

4条回答
  •  感情败类
    2020-12-01 13:22

    Use Icon class at first parameter for Drawable if api level >= 23(marshmallow)

    https://developer.android.com/reference/android/app/Notification.Action.Builder.html

    https://developer.android.com/sdk/api_diff/23/changes/android.app.Notification.Action.Builder.html

    example)

    Notification.Action action = new Notification.Action.Builder(
        Icon.createWithResource(this, R.drawable.ic_prev),
        "action string",
        pendingIntent).build();
    

提交回复
热议问题