I've got the following code:
//gallery is going to get open if notification is clicked.
Intent intent=new Intent(Intent.ACTION_VIEW,photoURI);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
PendingIntent pendingIntent = PendingIntent.getActivity(getContext(), 0, intent, 0);
//generate notification config and show notification
NotificationManager mNotificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = NotificationHandler.generateChannel("MyChannelId","MyChannelTitle",NotificationManager.IMPORTANCE_DEFAULT);
NotificationCompat.Builder mBuilder =
NotificationHandler.generateMaterialBuilder(
getContext().getApplicationContext(),
channel.getId(),
pendingIntent,
R.mipmap.ic_launcher_round,
"File Downloaded",
"Click to open File",
"Download Manager",
Notification.PRIORITY_MAX,
true);
mNotificationManager.createNotificationChannel(channel);
int length = mNotificationManager.getActiveNotifications().length;//add new record below isnted of replacing the current one
mNotificationManager.notify(length+1, mBuilder.build());
Basically, the code creates a image in a custom gallery folder (not shown in the code cause its irrelevant) and when the image get's created a create a notification which open the image when clicking on it. This works as expected.
However here is the issue: If I go to the gallery folder and delete the image and then click on the notification, the notification automatically opens the sms(messages) application rather than showing "No App Found" for e.g:
->
Is there any possibility to prevent opening the sms intent?
EDIT:
Here is the function which generates the NotificationBuilder:
public static NotificationCompat.Builder generateMaterialBuilder(Context appContext,
String channelId,
PendingIntent contentIntent,
int smallIcon,
String contentTitle,
String contentText,
String subText,
int priority,
boolean autoCancel) {
NotificationCompat.Builder mBuilder =new NotificationCompat.Builder(appContext, channelId);
mBuilder.setContentIntent(contentIntent); //this intent will get called when notification is clicked
mBuilder.setSmallIcon(smallIcon);
mBuilder.setContentTitle(contentTitle);
mBuilder.setContentText(contentText);
mBuilder.setSubText(subText);
mBuilder.setPriority(priority); //Show every detail on bar
mBuilder.setAutoCancel(autoCancel); //close notification when its being clicked
return mBuilder;
}
enter code here

