简体   繁体   English

可以在Android手机上设置指示器图标吗?

[英]Possible to set indicator icons on Android phones?

我想知道是否可以通过编程方式设置手机的指示器图标,例如GPS或正在进行的上传/下载等。

You have to use a Notification. 您必须使用通知。 Set the icon when initializing Notification class. 初始化Notification类时设置图标。 You can get more details here 您可以在此处获得更多详细信息

http://developer.android.com/guide/topics/ui/notifiers/notifications.html http://developer.android.com/guide/topics/ui/notifiers/notifications.html

Yes, Notifications is what you are looking for. 是的,通知是您想要的。 If you are notifying the user about something that just happened (for instance, a message arrived), you should use a plain Notification 1 . 如果您要通知用户刚刚发生的事情(例如,消息已到达),则应使用普通的Notification 1 However, if you want to notify the user that a service is running, then you should call startForeground() from your Service 2 , and stopForeground() when you are done with the operation. 但是,如果要通知用户服务正在运行,则应在服务2中调用startForeground(),并在操作完成后调用stopForeground()。

Some points to keep an eye out for: 注意以下几点:

  1. Only use notification for things the user cares about. 仅将通知用于用户关心的事情。 This may seem pretty obvious, but you'll find a surprising number of applications that notify the user of some background maintenance process that they don't really care (or can do anything) about. 这看起来似乎很明显,但是您会发现数量惊人的应用程序可以通知用户某些后台维护过程,他们实际上并不关心(或可以做任何事情)。

  2. Let the user customize what sort of things should trigger a notification. 让用户自定义应触发通知的事物类型。 It might be very annoying for the user if the phone is constantly beeping and vibrating. 如果手机不断发出蜂鸣声和振动,可能会给用户带来烦恼。

  3. Every notification should have an appropriate Intent that allows the user to take action on that particular notification, and that Intent should be the one that makes the most sense for that particular event -- for example, when the user taps a "new message" notification, he expects to be let to a screen where he can read the message. 每个通知都应具有适当的Intent,以使用户可以对该特定通知采取操作,并且该Intent应该是对该特定事件最有意义的一个Intent-例如,当用户点击“新消息”通知时,他希望将其放到可以阅读消息的屏幕上。 Sending the user to your application's home screen in that case will be much less useful. 在这种情况下,将用户发送到应用程序的主屏幕将没有太大用处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM