Android Service使用简单介绍
作为一个android初学者,经常对service的使用感到困惑。今天结合Google API 对Service这四大组件之一,进行简单使用说明。

START_NOT_STICKY- 系统将Service杀死之后,不重新创建Service。除非有pending intents 传过来要重新启动Service.
START_STICKY- 系统将Service杀死之后,重新创建Service并执行onstartCommand(),但是不传递最后的Intent,而是系统会在重新执行onStartCommand()时们传入一个空的intent.
START_REDELIVER_INTENT- 系统将Service杀死之后,重新创建Service并执行onstartCommand().传入最后接收的intent.
The IntentService does the following:
- Creates a default worker thread that executes all intents delivered to
onStartCommand()separate from your application's main thread. - Creates a work queue that passes one intent at a time to your
onHandleIntent()implementation, so you never have to worry about multi-threading. - Stops the service after all start requests have been handled, so you never have to call
stopSelf(). - Provides default implementation of
onBind()that returns null. - Provides a default implementation of
onStartCommand()that sends the intent to the work queue and then to youronHandleIntent()implementation.
Android Service使用简单介绍的更多相关文章
- javascript开发 ios和android app的简单介绍
先看几个名词解释: nodejs ionic,Cordova,phoneGap,anjularjs react-native,reactjs nodeJs 的介绍参见这里,写的很好http://www ...
- android之PackageManager简单介绍
PackageManager相关 本类API是对全部基于载入信息的数据结构的封装,包含下面功能: 安装,卸载应用查询permission相关信息 查询Application相关信息(applicati ...
- android Service 的简单使用(转)
1.要使用Service,首先就是在配置文件里吗添加Service,如果不填加,你的Service是不能够使用的.目前学到的方法有两种 方法一:<service android:enabl ...
- android MVP模式简单介绍
原文 http://zhengxiaopeng.com/2015/02/06/Android%E4%B8%AD%E7%9A%84MVP/ 前言 MVP作为一种MVC的演化版本在Android开发中受到 ...
- Android 使用 Application 简单介绍
Application 配置全局Context 第一步.写一个全局的单例模式的MyApplication继承自Application 覆盖onCreate ,在这个方法里面实例化Application ...
- android handler机制简单介绍
我们需要了解4个类: handler:处理者,用于发送和接收信息 massage:消息.里面可以存储消息的许多信息 looper:循环泵,用于循环取出消息队列中的消息 MessageQueue(一般不 ...
- Android ExpandableListActivity的简单介绍及小例子
Android中常常要用到ListView,但也经常要用到ExpandableListView,ListView是显示列表,而ExpandableListView显示的是分类的列表: 下面用一个例子来 ...
- android application类简单介绍(一)
每次应用程序执行时.应用程序的application类保持实例化的状态. 通过扩展applicaiton类,能够完毕下面3项工作: 1.对android执行时广播的应用程序级事件如低低内做出响应. 2 ...
- Android MediaScanner使用简单介绍
1. 运行扫描 仅仅有系统开机的时候才会运行MediaScanner,其他情景下须要手动运行扫描(拍摄,下载等). 手动运行扫描的方法是发送MediaScanner广播: 1.1 扫描指定文件: In ...
随机推荐
- apache 部署web.py
一.安装Mod_wsgi 1.先yum -y install httpd-devel,否则会提示没有apxs 2.如果在make时 wsgi报错apxs:Error: Command failed w ...
- PHP中对象的传值方式
对象的传值方式: 为什么对于对象,值传递和引用传递,这个情况下,他们似乎没有区别??? 这要从对象的数据的存储方式来理解: $o1 = new C1(); //这里创建一个对象o1,其存储结果如图所示 ...
- 服务器控件的异步请求——UpdatePanel和ScriptManager
aspx文件里面有以下一段代码 <body> <form id="form1" runat="server"> <div> ...
- Java知识点整理(一)
ArrayList和LinkedList的区别 1.ArrayList和LinkedList可想从名字分析,它们一个是Array(动态数组)的数据结构,一个是Link(链表)的数据结构,此外,它们两个 ...
- C# WebBrowser控件模拟登录
一.问题点: 1.模拟登录后,如果带有嵌套的iframe嵌套,不好读取iframe内容,可以直接指定iframe抓取网址 2.C# 清除WebBrowser控件的Session和Cookie 参考文档 ...
- C#使用 SharpSSH
准备试一把监控Linux机器 . 附件如下 :http://files.cnblogs.com/files/lclblog/Tamir.SharpSsh.zip
- elsarticle模板 去掉摘要前后的两条横线
参考:http://www.newsmth.net/nForum/#!article/TeX/316697?au=ericfire 如图:使用elsarticle模板修改PDF格式,去掉摘要前后的横线 ...
- 【Aizu2292】Common Palindromes(回文树)
[Aizu2292]Common Palindromes(回文树) 题面 Vjudge 神TMD日语 翻译: 给定两个字符串\(S,T\),询问\((i,j,k,l)\)这样的四元组个数 满足\(S[ ...
- 【BZOJ2115】Xor(线性基)
[BZOJ2115]Xor(线性基) 题面 BZOJ Description Input 第一行包含两个整数N和 M, 表示该无向图中点的数目与边的数目. 接下来M 行描述 M 条边,每行三个整数Si ...
- Sort Integers II
Given an integer array, sort it in ascending order. Use quick sort, merge sort, heap sort or any O(n ...