Wal*_*est 12 notifications android
当我添加通知时:
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.plus)
.setContentTitle(title)
.setAutoCancel(true)
.setContentText(text)
.setSound(RingtoneManager .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setLargeIcon(bm);
Run Code Online (Sandbox Code Playgroud)
我看到大图标和小图标: 
如何只设置大图标,不小.如果只使用setLargeIcon,我根本看不到通知,只是声音警报.
获取小图标ID,然后尝试隐藏它
int smallIconId = ctx.getResources().getIdentifier("right_icon", "id", android.R.class.getPackage().getName());
if (smallIconId != 0) {
if (notification.contentView!=null)
notification.contentView.setViewVisibility(smallIconId, View.INVISIBLE);
}
Run Code Online (Sandbox Code Playgroud)
试着看这篇文章也会有所帮助
我在api 18,23(三星j1,galaxy S6)上测试代码工作正常
| 归档时间: |
|
| 查看次数: |
12011 次 |
| 最近记录: |