没有未决的意向通知 [英] notification without pending intent

查看:96
本文介绍了没有未决的意向通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个通知,该通知将在顶部显示,但它不应该导航到任何网页,不应该有任何的onclick功能。

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.

这里是code,我都习惯了。

here is the code which i have 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);

任何人可以帮助我。谢谢@

Could anybody help me.@thanks

推荐答案

使用意图 wihtout有分量,像下面

Use Intent wihtout having component, like below

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

这是提供了一种方法,其中使用中不能打开活动

This is provide a way where use can't open an Activity.

这篇关于没有未决的意向通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆