开发学院手机开发Android 开发 Android HAL 阅读

Android HAL

 2010-04-21 06:36:00 来源:WEB开发网   
核心提示:static LedService led_srv;static Button btn;static boolean iflag = false;/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle s

static LedService led_srv;

static Button btn;

static boolean iflag = false;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

Log.i("Java App", "OnCreate");

led_srv = new LedService();

Log.i("Java App", "Load Java Serivce");

btn = (Button)this.findViewById(R.id.mybtn);

btn.setonClickListener(this);

}

public void onClick(View v) {

Log.i("Java App", "btnonClicked");

String title = new String();

if (iflag) {

title = led_srv.set_off();

btn.setText("Turn On");

setTitle(title);

iflag = false;

} else {

title = led_srv.set_on();

btn.setText("Turn Off");

setTitle(title);

iflag = true;

}

}

}

LedService.java 文件:

package com.hello.LedService;

import android.util.Log;

public final class LedService {

/*

* load native service.

*/

static {

Log.i ( "Java Service" , "Load Native Serivce LIB" );

System.loadLibrary ( "led_runtime" );

}

public LedService() {

int icount ;

Log.i ( "Java Service" , "do init Native Call" );

_init ();

icount = _get_count ();

Log.d ( "Java Service" , "Init OK " );

}

/*

* LED native methods.

*/

public String set_on() {

Log.i ( "com.hello.LedService" , "LED On" );

_set_on ();

return "led on" ;

}

public String set_off() {

Log.i ( "com.hello.LedService" , "LED Off" );

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

Tags:Android HAL

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接