WEB开发网
开发学院手机开发Android 开发 Android 实例展现如何不同程序间的Serivce调用 阅读

Android 实例展现如何不同程序间的Serivce调用

 2010-09-15 00:10:00 来源:WEB开发网   
核心提示:}};@Overridepublic void onCreate() {super.onCreate();Log.d("DemoService", "Service onCreate");nm = (NotificationManager) getSystemService(Se

}

};

@Override

public void onCreate() {

super.onCreate();

Log.d("DemoService", "Service onCreate");

nm = (NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE);

Notification n = new Notification(android.R.drawable.stat_notify_more,

"demo Service start", System.currentTimeMillis());

Intent praentA = new Intent(this, ServiceActivity.class);

PendingIntent pi = PendingIntent.getActivity(this, 0, praentA, 0);

n

.setLatestEventInfo(this, "Demo Running",

"com.shinestudio.demo.demoservice", pi);

n.flags = Notification.FLAG_ONGOING_EVENT;

nm.notify(0x1111, n);

}

@Override

public void onStart(Intent intent, int startId) {

super.onStart(intent, startId);

Bundle b = intent.getExtras();

if (b != null) {

pushData1 = b.getString("pushdata1");

pushData2 = b.getString("pushdata2");

}

}

@Override

public void onRebind(Intent intent) {

Log.d("DemoService", "Service onRebind");

super.onRebind(intent);

}

@Override

public boolean onUnbind(Intent intent) {

Log.d("DemoService", "Service onUnbind");

return super.onUnbind(intent);

}

@Override

public void onDestroy() {

Log.d("DemoService", "Service onDestory");

nm.cancel(0x1111);

super.onDestroy();

}

@Override

public IBinder onBind(Intent arg0) {

return dBinder;

}

}

ServiceActivity

package com.shinestudio.demo.service;

import android.app.Activity;

import android.content.ComponentName;

import android.content.Intent;

上一页  1 2 3 4 5 6 7 8  下一页

Tags:Android 实例 展现

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