Android 实例展现如何不同程序间的Serivce调用
2010-09-15 00:10:00 来源:WEB开发网package com.shinestudio.demo.service;
interface IDemoServiceBinder {
String getPushString();
void setPushString(String str);
}
AndroidManifesy.xml
< ?xml version="1.0" encoding="utf-8"?>
< manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shinestudio.demo.service" android:versionCode="1"
android:versionName="1.0">
< application android:icon="@drawable/icon" android:label="@string/app_name">
< activity android:name=".ServiceActivity" android:label="@string/app_name">
< intent-filter>
< action android:name="android.intent.action.MAIN" />
< category android:name="android.intent.category.LAUNCHER" />
< /intent-filter>
< /activity>
< service android:name="DemoService">
< intent-filter>
< action android:name="com.shinestudio.demo.demoservice">< /action>
< /intent-filter>
< /service>
< /application>
< /manifest>
B程序
package com.shinestudio.demo.reademo;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.shinestudio.demo.service.IDemoServiceBinder;
public class ReadActivity extends Activity {
更多精彩
赞助商链接