Android开发 --- Service 初步

来源:互联网 发布:sony hapz1es 软件 编辑:程序博客网 时间:2024/05/18 03:07

1.Service 是一个应用程序组件、没有图形界面、处理耗时长得操作; 不是一个单独的进程,也不是一个线程。

2.实现:  自定义的service需要继承Service类,并重写其中的方法。

onCreate(), onStartCommand(), onDestroy() ...

3.自定义的service需要在Manifest中注册

<service android:name=".xxxService" />  与 <activity /> 同级

4.使用

在自定义的Activity中 Intent it = new  Intent();

it.setClass(XXXActivity, XXXServie.class);

startService(it);

原创粉丝点击