使用IntentService
1.Service缺陷
由于Service本身存在以下两个问题:
(1)Service不会专门启动一条单独的进程,Service与他所在应用位于同一进程中;
(2)Service也不是专门一条新的线程,如果我们在Service中直接处理耗时的任务,那么就会导致应用程序出现假性"卡死"。如果我们需要在Service处理耗时任务,...
分类:
移动开发 时间:
2015-01-18 11:55:39
阅读次数:
212
什么是Service?
一、Service
1.Service简介
Service为Android四大组件之一,Service与Activity组件相似,都代表可执行的程序且有自己的生命周期,唯一的区别是Activity组件提供界面方便人机交互而Service只在后台运行且没有交互界面。需要注意的是,Service不是一个单独的进程或为了防止应用出现无反应错误单独的线程,它像其他应用...
分类:
移动开发 时间:
2015-01-18 11:55:22
阅读次数:
283
绑定本地Service并与之通信
通过上一篇博文的前3步,我们就算完成了一个Service及使用该Service的应用程序(Service为该应用程序的组成部分)。但当程序通过startService()和stopService()启动、关闭Service时,Service与访问者之间基本上不存在太多的关联,因此Service和访问者之间也无法进行通信、数据交换。如果我们希望开发的Se...
分类:
移动开发 时间:
2015-01-18 11:54:21
阅读次数:
200
跨进程调用Service(AIDL Service)
一、AIDL Service
1.什么是AIDL Service?
AIDL,即Android Interface Definition Language.是Android用于定义远程接口,AIDL接口定义语言的语法比较简单,这种接口定义语言并不是真正的编程语言,它只是定义两个进程之间的通信接口。AIDL的语法与Java接口很相似...
分类:
移动开发 时间:
2015-01-18 11:52:45
阅读次数:
304
(1)布局文件,一个简单的登录文件;
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:la...
分类:
移动开发 时间:
2015-01-17 20:56:16
阅读次数:
273
(1)在res--menu目录下的main.xml文件
...
分类:
移动开发 时间:
2015-01-17 16:35:54
阅读次数:
268
(1)在布局文件中创建一个listview:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
androi...
分类:
移动开发 时间:
2015-01-17 15:16:03
阅读次数:
229
(1)布局文件:用于弹出菜单的处罚button:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
andr...
分类:
移动开发 时间:
2015-01-17 15:14:34
阅读次数:
199
(1)布局文件没有做更改
(2)在res--menu目录下的main.xml文件中代码如下:
<item
android:id="...
分类:
移动开发 时间:
2015-01-17 13:57:26
阅读次数:
141
(1)布局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height...
分类:
移动开发 时间:
2015-01-16 19:18:58
阅读次数:
178