Android通过JNI操作串口《四》

来源:互联网 发布:c语言基础编程题 编辑:程序博客网 时间:2024/05/20 06:29

7.    config_options.xml

<?xmlversion="1.0"encoding="utf-8"?>

 

<PreferenceScreen

   xmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"

   android:key="video_call_fallback_setting"

   android:title="@string/tty_settings"

   android:persistent="false">

 

   <ListPreference

      android:key="tty_databits"

      android:title="@string/databits"

      android:persistent="true"

      android:entries="@array/databits_entries"

      android:entryValues="@array/databits_values"

      android:summary="data bits"/>

   <ListPreference

      android:key="tty_event"

      android:title="@string/event"

      android:persistent="true"

      android:entries="@array/event_entries"

      android:entryValues="@array/event_values"

      android:summary="data bits"/>

   <ListPreference

      android:key="tty_speed"

      android:title="@string/speed"

      android:persistent="true"

      android:entries="@array/speed_entries"

      android:entryValues="@array/speed_values"

      android:summary="data bits"/>

   <ListPreference

      android:key="tty_stopbits"

      android:title="@string/stopbits"

      android:persistent="true"

      android:entries="@array/stopbits_entries"

      android:entryValues="@array/stopbits_values"

      android:summary="data bits"/>

</PreferenceScreen>

 

8.    main.xml

<?xmlversion="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

   android:layout_width="fill_parent"

   android:layout_height="fill_parent"

   android:orientation="vertical">

   <LinearLayout

       android:layout_width="fill_parent"

       android:layout_height="60dip"

       android:orientation="horizontal"

       >

       <Button

           android:id="@+id/openOrcloseBtn"

           android:layout_gravity="center"

           android:layout_width="wrap_content"

           android:layout_height="wrap_content"

           android:text="@string/open"

           />

   </LinearLayout>

   <LinearLayout

       android:layout_width="fill_parent"

       android:layout_height="60dip"

       android:orientation="horizontal"

       >

       <EditText

           android:id="@+id/sendMsg"

           android:layout_gravity="left"

           android:layout_width="200dip"

           android:layout_height="50dip"

           />

       <Button

           android:id="@+id/sendBtn"

           android:layout_width="wrap_content"

           android:layout_height="wrap_content"

           android:text="@string/send"

           />

   </LinearLayout>

   

   <LinearLayout

       android:layout_width="fill_parent"

       android:layout_height="100dip"

       android:orientation="horizontal"

       >

       <TextView

           android:id="@+id/receiveMsg"

           android:layout_width="fill_parent"

           android:layout_height="wrap_content"

           android:text="@string/receiveData"/>

   </LinearLayout>

</LinearLayout>

9.    string.xml

<?xmlversion="1.0"encoding="utf-8"?>

<resources>

 

   <stringname="hello">Hello World, UARTCTLActivity!</string>

   <stringname="receiveData">Receive data show!</string>

   <stringname="app_name">UARTCTL</string>

   <stringname="open">Open</string>

   <stringname="close">Close</string>

   <stringname="send">Send</string>

   <stringname="config">Config</string>

   

   <stringname="tty_settings">Settings</string>

   <stringname="databits">Data bits</string>

   <stringname="event">Event</string>

   <stringname="speed">Speed</string>

   <stringname="stopbits">Stop bits</string>

   

   <string-arrayname="databits_entries">

       <item>-1</item>

       <item>7</item>

       <item>8</item>

   </string-array>

   <string-arrayname="databits_values">

       <item>-1</item>

       <item>7</item>

       <item>8</item>

   </string-array>

   

   <string-arrayname="event_entries">

       <item>Settings</item>

       <item>None</item>

       <item>Event</item>

       <item>Odd</item>

   </string-array>

   <string-arrayname="event_values">

       <item>Q</item>

       <item>N</item>

       <item>E</item>

       <item>O</item>

   </string-array>

   

   

   <string-arrayname="speed_entries">

       <item>-1</item>

       <item>B2400</item>

       <item>B4800</item>

       <item>B9600</item>

       <item>B115200</item>

   </string-array>

   <string-arrayname="speed_values">

       <item>-1</item>

       <item>2400</item>

       <item>4800</item>

       <item>9600</item>

       <item>115200</item>

   </string-array>

 

   <string-arrayname="stopbits_entries">

       <item>-1</item>

       <item>1</item>

       <item>2</item>

   </string-array>

   <string-arrayname="stopbits_values">

       <item>-1</item>

       <item>1</item>

       <item>2</item>

   </string-array>

</resources>

 

10.    Android.mk

LOCAL_PATH:=$(call my-dir)

include$(CLEAR_VARS)

 

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES :=$(call all-java-files-under,src)

 

#LOCAL_JAVA_LIBRARIES := uart-ctl

LOCAL_JNI_SHARED_LIBRARIES := uart_ctl #so文件打包到apk

   

LOCAL_PACKAGE_NAME := UARTCTL

#LOCAL_CERTIFICATE := platform

include$(BUILD_PACKAGE)

 

include$(LOCAL_PATH)/jni/Android.mk

include$(call all-makefiles-under,$(LOCAL_PATH))

 

11.    jni/Android.mk

LOCAL_PATH:=$(call my-dir)

include$(CLEAR_VARS)

 

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES:= \

   com_notioni_uart_manager_TtyNativeControl.cpp

LOCAL_C_INCLUDES := \

   $(JNI_H_INCLUDE) 

LOCAL_SHARED_LIBRARIES := \

   libcutils \

   libutils \

   libui \

   libandroid_runtime

 

LOCAL_PRELINK_MODULE := false

LOCAL_MODULE := uart_ctl

include$(BUILD_SHARED_LIBRARY)
0 0
原创粉丝点击