编程结束正在进行的通知 - 机器人 [英] Programatically ending an ongoing notification - android

查看:242
本文介绍了编程结束正在进行的通知 - 机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基于GPS的应用程序,刚刚开始加在我的UX功能,如通知和进度条,但我卡在使用持续的通知。

I am developing a GPS-based app and have just started adding in my UX features such as notifications and progress bars but I'm stuck on using an ongoing notification.

由于它是一个GPS应用程序,当启动用户跟踪,我成立了一个持续的通知,表明他们正在被跟踪,但我怎么阻止这个通知时,他们挖掘我的应用停止跟踪?我必须告诉NotifyManager的东西吗?基本上,我试图让音乐播放器具备的功能,如当用户presses发挥出现在玩的通知,但是当他们暂停,正在进行的打的通知被破坏。

As it is a GPS app, when user tracking is started, I set up an ongoing notification to show that they are being tracked but how do I stop this notification when they tap "stop tracking" in my app? Do I have to tell the NotifyManager something? I'm basically trying to get the functionality that music players have, as in the "playing" notification appears when the user presses play, but when they pause, that ongoing "playing" notification is destroyed.

另外,我从来没有与GPS合作过,但我必须要对此的服务,使用户不会被停止,如果我的应用程序是由OS取出内存跟踪?或者,是不是会发生呢?

Also, I've never worked with GPS before but should I be going about this in a Service so that the user won't stop being tracked if my app is taken out of memory by the OS? Or would that not happen?

感谢您的时间,

InfinitiFizz

InfinitiFizz

推荐答案

我也没有做什么用的通知,但你可以试试这个:

I haven't done much with notifications but you might try this:

NotificationManager.cancel(id); // Where 'id' is the id of your notification

更换 NotificationManager 与它的实例,当然,名称。

Replacing NotificationManager with the name of your instance of it, of course.

文档:的http://developer.android.com/reference/android/app/NotificationManager.html#cancel%28int%29

或者这样:

Notification.Builder.setAutoCancel(true);

<一个href=\"http://developer.android.com/reference/android/app/Notification.Builder.html#setAutoCancel%28boolean%29\" rel=\"nofollow\">http://developer.android.com/reference/android/app/Notification.Builder.html#setAutoCancel%28boolean%29

这篇关于编程结束正在进行的通知 - 机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆