zer*_*obe 15 notifications android status
我有一个显示大图的通知.
有没有办法从此视图中删除蜂窝和上方设备中的较小图标?
显然仍然保留顶部状态栏的小图标

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
// Set required fields, including the small icon, the
// notification title, and text.
.setSmallIcon(R.drawable.ic_notify_status_new)
.setContentTitle(title)
.setContentText(text)
// All fields below this line are optional.
// Use a default priority (recognized on devices running Android
// 4.1 or later)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
// Provide a large icon, shown with the notification in the
// notification drawer on devices running Android 3.0 or later.
.setLargeIcon(picture)
.setContentIntent(
PendingIntent.getActivity(
context,
0,
notiIntent,
PendingIntent.FLAG_UPDATE_CURRENT)
);
builder = getNotiSettings(builder);
notify(context, builder.build());
Run Code Online (Sandbox Code Playgroud)
Ziv*_*ten 13
生成通知后添加此代码.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int smallIconViewId = getResources().getIdentifier("right_icon", "id", android.R.class.getPackage().getName());
if (smallIconViewId != 0) {
if (notif.contentIntent != null)
notif.contentView.setViewVisibility(smallIconViewId, View.INVISIBLE);
if (notif.headsUpContentView != null)
notif.headsUpContentView.setViewVisibility(smallIconViewId, View.INVISIBLE);
if (notif.bigContentView != null)
notif.bigContentView.setViewVisibility(smallIconViewId, View.INVISIBLE);
}
}
Run Code Online (Sandbox Code Playgroud)
其中"notif"是您建立的通知,
| 归档时间: |
|
| 查看次数: |
8690 次 |
| 最近记录: |