CPU:RK3288
系统:Android 5.1
功能:上层 app 控制 led 亮灭
开发板:Firefly RK3288
MainActivity.java
package com.aaron.led; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Button; import com.aaron.link.LedNative; public class MainActivity extends AppCompatActivity { private final String TAG = "LedApp"; Button led_on; Button led_off; LedNative lednative; View.OnClickListener clickListener = new View.OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_on: Log.d(TAG, "Led On"); lednative.onDev(); break; case R.id.btn_off: Log.d(TAG, "Led Off"); lednative.offDev(); break; default: break; } } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); led_on = findViewById(R.id.btn_on); led_off = findViewById(R.id.btn_off); led_on.setOnClickListener(clickListener); led_off.setOnClickListener(clickListener); lednative = new LedNative(); lednative.openDev(); Log.d(TAG, "open Dev"); } protected void onDestroy() { super.onDestroy(); lednative.closeDev(); Log.d(TAG, "close Dev"); } }
LedNative.java
package com.aaron.link; /** * Created by Administrator on 2018/3/20. */ public class LedNative { static{ System.loadLibrary("firefly_led_jni"); } public native void openDev(); public native int onDev(); public native int offDev(); public native int closeDev(); }