NotificationCompat.Builder is deprecated

前端 未结 1 500
心在旅途
心在旅途 2021-01-27 06:42
private void sendNotification(Context context, String dnsModel) {
    Intent intentAction = new Intent(context, MainActivity.class);

    intentAction.putExtra("dns         


        
相关标签:
1条回答
  • 2021-01-27 07:21

    Creating a notification channel is not that hard. Here is some code: https://developer.android.com/training/notify-user/channels#CreateChannel

    You can execute that code in your MainActivity or your Application class on app startup.

    Once you created the channel id, you can use it with NotificationCompat.Builder(Context context, String channelId)

    EDIT

    The CHANNEL_ID is a simple String. You can for example add this to a constants file:

    public static final String CHANNEL_ID = "your.package.name.notificationChannelId"
    

    You can now use this constants hwen creating your notification channel and when calling NotificationCompat.Builder(Context context, String channelId)

    0 讨论(0)
提交回复
热议问题