
For notification to launch our app we need to use Pending Intent. We are continuing here with the same example I took in my previous article (please refer it) and we are gonna notify the user every now and then to drink water.Īlso we want our notification to launch the app when clicked so that we can tap the image to update water count when drank. From nougat, notifications started to show the name of the app which is firing them From lollipop, notifications started including few actions in them for limited data available in them, such as ans or reject a call from notification itself when it arrives. These have become a lighweight method to interact directly with the apps. Notificatons are a way to notify the user of background updates as there is no use of an background update if it doesn’t even get to be known, right ? Here I am gonna show you how to build a Pending Intent taking you from the beginning that is definition of Pending Intent to all over a working example. Since you are using AlarmManager you should be able to use the IMMUTABLE flag.Creating Pending Intent in Android - A step by step guide You need to do this: pendingIntent = PendingIntent.getBroadcast(service, 0, new Intent(Īction), PendingIntent.FLAG_UPDATE_CURRENT | Help me to fix the issue ERROR IN ANDROID STUDIO IMAGE PendingIntent = PendingIntent.getBroadcast(service, 0, new Intent(Īction), PendingIntent.FLAG_UPDATE_CURRENT) Service.registerReceiver(alarmReceiver, new IntentFilter(action)) Log.d(TAG, "Register alarmreceiver to MqttService"+ action)

String action = MqttServiceConstants.PING_SENDER

This is a place in AlarmPingSender.java where the error occurred public void start() I can't update the pending intent flag in android studio project coding Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
