gpt4 book ai didi

android如何从左上角屏幕中删除通知小图标

转载 作者:太空狗 更新时间:2023-10-29 15:26:11 26 4
gpt4 key购买 nike

我有这段构建通知的代码,我需要删除左上角屏幕上的小图标,我需要询问是否有任何方法可以在创建通知时阻止显示此图标

        String ns = Context.NOTIFICATION_SERVICE;
NotificationManager notificationManager =
(NotificationManager) getSystemService(ns);

RemoteViews notificationView = new RemoteViews(getPackageName(),
R.layout.mynotification);
Notification.Builder notification = new Notification.Builder(
getApplicationContext())
.setTicker(tickerText)
.setSmallIcon(R.drawable.ic_launcher)// here how can i make it null or transparent
.setAutoCancel(true)
.setContentIntent(mContentIntent)

.setVibrate(mVibratePattern)
.setContent(notificationView);


//the intent that is started when the notification is clicked (works)
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingNotificationIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);



//this is the intent that is supposed to be called when the
//button is clicked
Intent switchIntent = new Intent(this, switchButtonListener.class);
PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 0,
switchIntent, PendingIntent.FLAG_UPDATE_CURRENT);

notificationView.setOnClickPendingIntent(R.id.closeOnFlash,
pendingSwitchIntent);
notificationView.setOnClickPendingIntent(R.id.appName,
pendingSwitchIntent);
Notification not = notification.build();
not.flags=Notification.FLAG_ONGOING_EVENT;

notificationManager.notify(1, not);

我需要将通知留在状态栏上,但不显示左上角的小图标

最佳答案

好的,现在我找到了解决方案:O 只需要做这个

.setSmallIcon(android.R.color.transparent)

关于android如何从左上角屏幕中删除通知小图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33479157/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com