Notification with no pending intent

I need to create a notification that will be displayed at the top, but should not go to any page, there should not be any onclick function.

here is the code i used.

notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); myNotification = new Notification(R.drawable.icon,"Notification!", System.currentTimeMillis()); Context context = getApplicationContext(); String notificationTitle = "Message"; String notificationText = Msg; Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(myBlog), context, com.gurupro.LiveChat.class); myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TOP); //PendingIntent pendingIntent = PendingIntent.getActivity(Home.this, 0, myIntent, 0); myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); //myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); myNotification.defaults |= Notification.DEFAULT_SOUND; myNotification.flags |= Notification.FLAG_AUTO_CANCEL; myNotification.setLatestEventInfo(context, notificationTitle,notificationText, pendingIntent); notificationManager.notify(MY_NOTIFICATION_ID, myNotification); 

Can someone help me. @thanks

+7
source share
1 answer

Use Intent with a component like below

 PendingIntent contentIntent = PendingIntent.getActivity( getApplicationContext(), 0, new Intent(), // add this PendingIntent.FLAG_UPDATE_CURRENT); 

This provides a way in which use cannot open an Activity .

+18
source

All Articles