创建Android Application工程:使用Eclipse的Android插件ADT创建Android工程,工程名称为Gpio,创建完成后将工程目录拷贝到packages/apps/文件夹下,并删除工程目录下的gen文件夹,不删除的话会造成类重复的错误。
src/com/android/gpio/Gpio.java:
package com.android.gpio;
import com.android.gpio.R;
import android.app.Activity;
import android.os.ServiceManager;
import android.os.Bundle;
import android.os.IGpioService;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Gpio extends Activity implements OnClickListener {
private final static String LOG_TAG = "com.android.Gpio";
private IGpioService gpioService = null;
private Button setButton = null;
private Button clearButton = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle sav