Android学习笔记(二十三)

Service

 

ServiceActivity

package org.wp.activity;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class CustomService extends Service {
	private static final String TAG = "CustomService";

	@Override
	public IBinder onBind(Intent intent) {
		Log.i(TAG, "onBind()");
		return null;
	}

	@Override
	public void onCreate() {
		Log.i(TAG, "onCreate()");
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		Log.i(TAG, "onStartCommand()");
		Log.i(TAG, "flags--->" + flags);
		Log.i(TAG, "startId--->" + startId);
		return START_NOT_STICKY;
	}

	@Override
	public void onDestroy() {
		Log.i(TAG, "onDestroy()");
	}
}

 

CustomService

package org.wp.activity;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class CustomService extends Service {
	private static final String TAG = "CustomService";

	@Override
	public IBinder onBind(Intent intent) {
		Log.i(TAG, "onBind()");
		return null;
	}

	@Override
	public void onCreate() {
		Log.i(TAG, "onCreate()");
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		Log.i(TAG, "onStartCommand()");
		Log.i(TAG, "flags--->" + flags);
		Log.i(TAG, "startId--->" + startId);
		return START_NOT_STICKY;
	}

	@Override
	public void onDestroy() {
		Log.i(TAG, "onDestroy()");
	}
}

 

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	package="org.wp.activity" 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=".CustomService" />
	</application>
	<uses-sdk android:minSdkVersion="7" />
</manifest>

 

 

 

你可能感兴趣的:(android,xml,OS)