WEB开发网
开发学院手机开发Android 开发 Android实现开机自启动Service 阅读

Android实现开机自启动Service

 2010-06-22 02:26:00 来源:WEB开发网   
核心提示:super.onStart(intent, startId);}public IBinder onBind(Intent intent) {Log.i(TAG, "> TService.onBind");return null;}public class LocalBinder extends

super.onStart(intent, startId);

}

public IBinder onBind(Intent intent) {

Log.i(TAG, "============> TService.onBind");

return null;

}

public class LocalBinder extends Binder {

public TService getService() {

return TService.this;

}

}

public boolean onUnbind(Intent intent) {

Log.i(TAG, "============> TService.onUnbind");

return false;

}

public void onRebind(Intent intent) {

Log.i(TAG, "============> TService.onRebind");

}

public void onDestroy() {

Log.i(TAG, "============> TService.onDestroy");

notificationManager.cancel(R.string.service_start);

objHandler.removeCallbacks(mTasks);

super.onDestroy();

}

private void showNotification() {

Notification notification = new Notification(R.drawable.icon,

"SERVICE START", System.currentTimeMillis());

Intent intent = new Intent(this, testService.class);

intent.putExtra("FLG", 1);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0,

intent, 0);

notification.setLatestEventInfo(this, "SERVICE", "SERVICE START",

contentIntent);

notificationManager.notify(R.string.service_start, notification);

}

}

做一个主程序:

package com.testService;

import android.app.Activity;

import android.content.Context;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.Toast;

public class testService extends Activity {

private Button button01;

private Button button02;

上一页  1 2 3 4  下一页

Tags:Android 实现 开机

编辑录入:coldstar [复制链接] [打 印]
赞助商链接