vivo手机不能显示notification的解决方法

2018-12-02  本文已影响0人  水枂

先吐槽一下,今天写了一个通知,在真机调试 (vivo x9)无论如何都显示不出来,但是在模拟器Android4却可以显示,开始以为Android7的显示变了,因为8就变了有点不同,试了好多方法搞了一下午也没弄出来。

最后发现要打开手机的设置就可以了,具体解决方法如下:

在 VIVO X9手机上手动设置的方式:

    Settings -- More settings -- Applications -- All -- 目标 App -- Notifications -- 打开 Allow notification 

如图找到通知后点进去,打开通知就可以了

下面是示例代码:

```

//设置单击通知后所打开的详细界面

PendingIntent pendingIntent = PendingIntent.getActivity(this,0,

new Intent(this, NotificationActivity.class),0);

//获得res对于的资源对象

Resources res =this.getResources();

//创建通知对象

Notification.Builder builder =new Notification.Builder(this);

builder.setSmallIcon(R.mipmap.h)

.setLargeIcon(BitmapFactory.decodeResource(res, R.mipmap.h))

.setContentTitle("通知发送人")

.setContentText("我是详细的通知")

.setContentIntent(pendingIntent).build();

//发送通知

mNotificationManager.notify(NOTIFY_ME_ID, builder.build());

```

   

           

上一篇 下一篇

猜你喜欢

热点阅读