您的位置:首页 > 移动开发 > Android开发

Android通过JNI操作串口《四》

2014-04-08 18:17 260 查看
7.
config_options.xml

<?xml
version="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

<?xml
version="1.0"
encoding="utf-8"?>
<LinearLayout
xmlns: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

<?xml
version="1.0"
encoding="utf-8"?>
<resources>


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

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

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

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

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

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

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



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

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

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

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

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



<string-array
name="databits_entries">

<item>-1</item>

<item>7</item>

<item>8</item>

</string-array>

<string-array
name="databits_values">

<item>-1</item>

<item>7</item>

<item>8</item>

</string-array>



<string-array
name="event_entries">

<item>Settings</item>

<item>None</item>

<item>Event</item>

<item>Odd</item>

</string-array>

<string-array
name="event_values">

<item>Q</item>

<item>N</item>

<item>E</item>

<item>O</item>

</string-array>





<string-array
name="speed_entries">

<item>-1</item>

<item>B2400</item>

<item>B4800</item>

<item>B9600</item>

<item>B115200</item>

</string-array>

<string-array
name="speed_values">

<item>-1</item>

<item>2400</item>

<item>4800</item>

<item>9600</item>

<item>115200</item>

</string-array>


<string-array
name="stopbits_entries">

<item>-1</item>

<item>1</item>

<item>2</item>

</string-array>

<string-array
name="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_J***A_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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: