Welcome 微信登录

首页 / 操作系统 / Linux / Android service 精辟解说

本地服务所谓本地服务,其实就是完全服务于一个进程的组件。本地服务的这种特性决定了它有特别的启动方式。通常这类服务的典型案例,就是邮件轮询。 调用Context.startService()启动服务 package net.bpsky; import Android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.app.Service;import android.content.Intent;import android.os.IBinder; public class DoudingService extends Service {         private NotificationManager notificationMgr;     @Override    public IBinder onBind(Intent arg0) {        // TODO Auto-generated method stub        return null;    }         @Override    public void onCreate(){        super.onCreate();                 notificationMgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);        displayNotificationMessage("Starting Background Service!");        Thread thr = new Thread(null,new ServiceWorker(),"BackgroundService");        thr.start();
版权所有©石家庄振强科技有限公司2024 冀ICP备08103738号-5 网站地图