2015-11-02 67 views
3

删除通知小图标我有这样的代码,建立通知,我需要删除左上角屏幕上的小图标,我要问,如果有妨碍显示该图标的任何方法时创建通知机器人如何从屏幕左上角

 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); 

我需要留在状态栏上但没有在上面显示的小图标通知左

+0

你有没有尝试删除setSmallIcon(R.drawable.ic_launcher) –

+0

是的,然后整个通知被删除! – Amalo

回答

-1

还好现在我找到了解决办法:o只需要进行这项

.setSmallIcon(android.R.color.transparent) 
+0

这将删除通知栏的图标收到推送时 – Sergio76

相关问题