我通过android发出通知,其中显示了我的应用图标,但我无法将其删除。怎么办呢?
这是我的代码:
public void MakeEventsNotification(int num){
Intent myIntent = new Intent(this, BazardanApp.class);
Bundle parcerable = new Bundle();
parcerable.putChar("clicknotify", 'E');
myIntent.putExtra("clicknotify", parcerable);
PendingIntent myPendingIntent = PendingIntent.getActivity(this, 1, myIntent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setContentTitle("بازاردان")
.setContentText("شما " + num + " رویداد جدید در بازاردان دارید ...")
.setNumber(num)
.setSmallIcon(R.drawable.iconminmin)
.setLargeIcon(BitmapFactory.decodeResource(that.getResources(), R.drawable.iconmin))
.setContentIntent(myPendingIntent)
.setAutoCancel(true);
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
builder.setSound(uri);
long[] v = {500,1000};
builder.setVibrate(v);
Notification myNotification;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
myNotification = builder.addAction(R.drawable.icon, "نمایش رویدادها", myPendingIntent).build();
}else {
myNotification = builder.getNotification();
}
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, myNotification);
}
答案 0 :(得分:0)
你已经使用了setLargeIcon()只是注释它的行吗
public void MakeEventsNotification(int num){
Intent myIntent = new Intent(this, BazardanApp.class);
Bundle parcerable = new Bundle();
parcerable.putChar("clicknotify", 'E');
myIntent.putExtra("clicknotify", parcerable);
PendingIntent myPendingIntent = PendingIntent.getActivity(this, 1, myIntent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setContentTitle("بازاردان")
.setContentText("شما " + num + " رویداد جدید در بازاردان دارید ...")
.setNumber(num)
.setSmallIcon(R.drawable.iconminmin)
//.setLargeIcon(BitmapFactory.decodeResource(that.getResources(), R.drawable.iconmin))
.setContentIntent(myPendingIntent)
.setAutoCancel(true);
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
builder.setSound(uri);
long[] v = {500,1000};
builder.setVibrate(v);
Notification myNotification;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
myNotification = builder.addAction(R.drawable.icon, "نمایش رویدادها", myPendingIntent).build();
}else {
myNotification = builder.getNotification();
}
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, myNotification);
}
有关通知的更多信息,请参阅 - > http://developer.android.com/guide/topics/ui/notifiers/notifications.html
并且这一个 - > http://developer.android.com/training/notify-user/build-notification.html