没有未决意图的通知 [英] notification without pending intent
本文介绍了没有未决意图的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个通知,该通知将显示在顶部,但不应导航到任何页面,不应具有任何点击功能.
I need to create a notification,which will display in the top but it should not navigate to any page,should not have any onclick function.
这是我使用过的代码.
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);
谁能帮帮我.@thanks
Could anybody help me.@thanks
推荐答案
Use Intent
没有组件,如下图
Use Intent
wihtout having component, like below
PendingIntent contentIntent = PendingIntent.getActivity(
getApplicationContext(),
0,
new Intent(), // add this
PendingIntent.FLAG_UPDATE_CURRENT);
这提供了一种方法,使用户无法打开Activity
.
This is provide a way where use can't open an Activity
.
这篇关于没有未决意图的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文