android点击通知并关闭,单击后,通知android不会关闭

我正在尝试创建通知果冻豆(api 16)并且我的通知有问题,这是我的代码

public class CreateNotification extends AsyncTask {

int style = NORMAL;

public CreateNotification(int style) {

this.style = style;

}

@Override

protected Void doInBackground(Void... params) {

Notification noti = new Notification();

noti = setNormalNotification();

noti.defaults |= Notification.DEFAULT_LIGHTS;

noti.defaults |= Notification.DEFAULT_VIBRATE;

noti.defaults |= Notification.DEFAULT_SOUND;

noti.flags |= Notification.FLAG_ONLY_ALERT_ONCE;

mNotificationManager.notify(0, noti);

return null;

}

}

private Notification setNormalNotification() {

Bitmap remote_picture = null;

remote_picture = getBitmapFromURL(sample_url);

// Setup an explicit intent for an ResultActivity to receive.

Intent resultIntent = new Intent(this, DetailActivity.class);

// TaskStackBuilder ensures that the back button follows the recommended convention for the back key.

TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

// Adds the back stack for the Intent (but not the Intent itself).

stackBuilder.addParentStack(ResultActivity.class);

// Adds the Intent that starts the Activity to the top of the stack.

stackBuilder.addNextIntent(resultIntent);

PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

return new NotificationCompat.Builder(this)

.setSmallIcon(R.drawable.ic_launcher)

.setAutoCancel(true)

.setLargeIcon(remote_picture)

.setContentIntent(resultPendingIntent)

.addAction(R.drawable.ic_launcher, "Open detail", resultPendingIntent)

.addAction(R.drawable.ic_launcher, "Close", resultPendingIntent)

.setContentTitle("Normal Notification")

.setContentText("This is an example of a Normal Style.").build();

}

在这个

.addAction(R.drawable.ic_launcher, "Open detail", resultPendingIntent)

.addAction(R.drawable.ic_launcher, "Close", resultPendingIntent)

如果我点击打开详细信息或关闭按钮,通知不会关闭..如何解决?谢谢,抱歉我的英格兰

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值