前言
本文探讨一下kotlin和jni的混合使用,综合考虑,jni的入口函数采用java编程,其他的android业务逻辑采用kotlin编程。c程序内容是自己在ubuntu环境下编译so文件导入工程实现代码安全。
这个ui是用来控制开发板的led的,这里把控制led的代码改为普通的日志输出,不影响普通的使用
1、 UI布局
直接把xml文件贴出来,只是测试demo,写的比较随便
布局里面 就是按钮和checkbox
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.act64.myapplication.MainActivity"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="81dp">
android:id="@+id/sample_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Hello World!"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintHorizontal_bias="0.097"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="@+id/all_btn"
android:text="All ON/OFF" />
android:id="@+id/led1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="LED1" />
android:id="@+id/led2"
android:layout_width="match_p