android--service 你应该记住的一些事-2
来源:互联网 发布:淘宝上如何分期付款 编辑:程序博客网 时间:2024/06/10 22:39
[1].However, if you want the service to send a result back, then the client that starts the service can create a PendingIntent
for a broadcast (with getBroadcast()
) and deliver it to the service in the Intent
that starts the service. The service can then use the broadcast to deliver a result.
[2].Multiple requests to start the service result in multiple corresponding calls to the service's onStartCommand()
. However, only one request to stop the service (with stopSelf()
or stopService()
) is required to stop it.
[3].For example, a music player that plays music from a service should be set to run in the foreground, because the user is explicitly aware of its operation. To request that your service run in the foreground, call startForeground()
. This method takes two parameters: an integer that uniquely identifies the notification and the Notification
for the status bar.
The integer ID you give to startForeground()
must not be 0.
[4].To remove the service from the foreground, call stopForeground()
. This method takes a boolean, indicating whether to remove the status bar notification as well. This method does not stop the service. However, if you stop the service while it's still running in the foreground, then the notification is also removed.
[5].These two paths are not entirely separate. That is, you can bind to a service that was already started with startService()
. For example, a background music service could be started by calling startService()
with an Intent
that identifies the music to play. Later, possibly when the user wants to exercise some control over the player or get information about the current song, an activity can bind to the service by calling bindService()
. In cases like this, stopService()
or stopSelf()
does not actually stop the service until all clients unbind.
[6].
[7].If the service is started, the active lifetime ends the same time that the entire lifetime ends (the service is still active even after onStartCommand()
returns). If the service is bound, the active lifetime ends when onUnbind()
returns.
- android--service 你应该记住的一些事-2
- android--service 你应该记住的一些事-1
- android--BitMap 你应该记住的一些事-1
- android--Process and Thread 你应该记住的一些事
- android--Content Provider 你应该记住的一些事-1
- android--View 你应该记住的一些事
- android--Touch Events 你应该记住的一些事
- Android Service 你应该掌握的东西
- 应该记住的一些sql单词
- 人生应该记住的一些话
- android之service,你应该知道的一切
- 使用Android Studio时你应该知道的一些配置
- 你应该知道的一些Android ADB 命令
- 你应该知道的一些Android ADB 命令
- 最近项目中应该记住的一些经验
- 我们应该尽量记住一些术语的全称
- 我们应该尽量记住一些术语的全称
- 索尼的Xperia X8手机 - 你应该记住
- 跨服务器备份/还原MySQL表
- 关于触发器对扩展表插入操作引发的违反主键的唯一约束条件
- 内部类(inner class)
- Win32多线程之多线程设计成功的关键
- UVA - 1335 Beijing Guards
- android--service 你应该记住的一些事-2
- 如何检测单链表中的是否存在环
- 【感悟】迷茫时的坚持最可贵
- CentOS64+Qt+Mysql+ftp+无密钥传输的配置<详细过程>
- 腾讯群关系数据泄漏下载
- Java ClassLoader详解
- UVa 10404 Bachet's Game (DP&博弈)
- 完美实现Silverlight动态加载
- Ansi与Unicode