• Android开发ABC之:Service


    下面是SDK doc对Service的描述:

    A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use. Each service class must have a corresponding <service> declaration in its package's AndroidManifest.xml. Services can be started with Context.startService() and Context.bindService().

    几个要点:

    Service是应用的一个组件,当应用想要执行长时间的任务,并且不跟用户交互或者为其他应用提供功能时使用。Service并不代表一个新的进程或者线程,而是在宿主进程的主线程中运行,所以它并不适合Computing intensive的任务,比如播放MP3或者视频编解码等,需要创建新线程来完成。

    每个service类都必须在AndroidManifest.xml中声明,否则,会报告“Unable to start service Intent U=0: not found”错误。

    Service不能自己启动,只能使用Context.startService() 和 Context.bindService()启动。

    下面是来自SDK doc:

    • A facility for the application to tell the system about something it wants to be doing in the background (even when the user is not directly interacting with the application). This corresponds to calls to Context.startService(), which ask the system to schedule work for the service, to be run until the service or someone else explicitly stop it.
    • A facility for an application to expose some of its functionality to other applications. This corresponds to calls to Context.bindService(), which allows a long-standing connection to be made to the service in order to interact with it.
  • 相关阅读:
    6.金额中带有逗号不能直接parseFloat
    5-不要在ajax中return false不会生效的
    4.xx is not defined at HTMLAnchorElement.onclick 的问题
    3.git更新地址也更改
    2.文件上传后没有权限不够
    第三章
    oracle-sql
    华为杯 数模
    Learning Dynamic Context Graphs for Predicting Social Events
    图神经网络
  • 原文地址:https://www.cnblogs.com/whyandinside/p/2904775.html
Copyright © 2020-2023  润新知