android取消服务,android-滑动以取消服务通知

认为这根本不是问题,但仍然如此.

无论我做什么,“我的服务”通知都不想滑动清除.

我有一个进度通知,该通知在服务中使用startForeground(id,Notification)启动.

这是我的构建方式:

public Notification createErrorNotification(String message) {

NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext());

Intent showAppIntent = new Intent(getApplicationContext(), MainActivity.class);

showAppIntent.setAction(Intent.ACTION_MAIN);

showAppIntent.addCategory(Intent.CATEGORY_LAUNCHER);

PendingIntent pendingShowAppIntent = PendingIntent.getActivity(getApplicationContext(), 10,

showAppIntent, PendingIntent.FLAG_CANCEL_CURRENT);

builder.setContentTitle(getString(R.string.label_download_error))

.setWhen(0)

.setContentText(message)

.setContentIntent(pendingShowAppIntent)

.setAutoCancel(true)

.setOngoing(false)

.setSmallIcon(R.drawable.ic_launcher);

return builder.build();

}

在某些时候,如果发生错误,我将进度通知替换为所描述的错误通知,并禁用“进行中”等功能.

我也完全停止服务:

private void stopService() {

stopSelf();

taskThread.stopLooper();

downloadHandler.stopExecution();

downloadHandler = null;

taskThread = null;

}

并致电

stopForeground(false);

false-因为我希望通知在屏幕上保留并被用户关闭.

但是清除滑动功能根本行不通.

如果我调用stopForeground(true)-通知已正确删除.

有人有任何想法我在这里做错了吗?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值