資源簡介
android開發藍牙demo

代碼片段和文件信息
/*
?*?Copyright?(C)?2009?The?Android?Open?Source?Project
?*
?*?Licensed?under?the?Apache?License?Version?2.0?(the?“License“);
?*?you?may?not?use?this?file?except?in?compliance?with?the?License.
?*?You?may?obtain?a?copy?of?the?License?at
?*
?*??????http://www.apache.org/licenses/LICENSE-2.0
?*
?*?Unless?required?by?applicable?law?or?agreed?to?in?writing?software
?*?distributed?under?the?License?is?distributed?on?an?“AS?IS“?BASIS
?*?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND?either?express?or?implied.
?*?See?the?License?for?the?specific?language?governing?permissions?and
?*?limitations?under?the?License.
?*/
package?com.example.android.BluetoothChat;
import?android.app.ActionBar;
import?android.app.Activity;
import?android.bluetooth.BluetoothAdapter;
import?android.bluetooth.BluetoothDevice;
import?android.content.Intent;
import?android.os.Bundle;
import?android.os.Handler;
import?android.os.Message;
import?android.util.Log;
import?android.view.KeyEvent;
import?android.view.Menu;
import?android.view.MenuInflater;
import?android.view.MenuItem;
import?android.view.View;
import?android.view.Window;
import?android.view.View.onclickListener;
import?android.view.inputmethod.EditorInfo;
import?android.widget.ArrayAdapter;
import?android.widget.Button;
import?android.widget.EditText;
import?android.widget.ListView;
import?android.widget.TextView;
import?android.widget.Toast;
/**
?*?This?is?the?main?Activity?that?displays?the?current?chat?session.
?*/
public?class?BluetoothChat?extends?Activity?{
????//?Debugging
????private?static?final?String?TAG?=?“BluetoothChat“;
????private?static?final?boolean?D?=?true;
????//?Message?types?sent?from?the?BluetoothChatService?Handler
????public?static?final?int?MESSAGE_STATE_CHANGE?=?1;
????public?static?final?int?MESSAGE_READ?=?2;
????public?static?final?int?MESSAGE_WRITE?=?3;
????public?static?final?int?MESSAGE_DEVICE_NAME?=?4;
????public?static?final?int?MESSAGE_TOAST?=?5;
????//?Key?names?received?from?the?BluetoothChatService?Handler
????public?static?final?String?DEVICE_NAME?=?“device_name“;
????public?static?final?String?TOAST?=?“toast“;
????//?Intent?request?codes
????private?static?final?int?REQUEST_CONNECT_DEVICE_SECURE?=?1;
????private?static?final?int?REQUEST_CONNECT_DEVICE_INSECURE?=?2;
????private?static?final?int?REQUEST_ENABLE_BT?=?3;
????//?Layout?Views
????private?ListView?mConversationView;
????private?EditText?mOutEditText;
????private?Button?mSendButton;
????//?Name?of?the?connected?device
????private?String?mConnectedDeviceName?=?null;
????//?Array?adapter?for?the?conversation?thread
????private?ArrayAdapter?mConversationArrayAdapter;
????//?String?buffer?for?outgoing?messages
????private?StringBuffer?mOutStringBuffer;
????//?Local?Bluetooth?adapter
????private?BluetoothAdapter?mBluetoothAdapter?=?null;
????//?Member?object?for?the?chat?services
????private?BluetoothChatService?mChatService?=?null;
????@Override
????public?void?onCreate(Bundle?savedInstanceState)?{
????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\
?????文件????????1804??2013-02-27?21:17??BluetoothChat\AndroidManifest.xm
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\res\
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\res\drawable\
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\res\drawable-hdpi\
?????文件????????5589??2013-02-27?21:17??BluetoothChat\res\drawable-hdpi\app_icon.png
?????文件????????4182??2013-02-27?21:17??BluetoothChat\res\drawable\app_icon.png
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\res\layout\
?????文件????????1532??2013-02-27?21:17??BluetoothChat\res\layout\custom_ti
?????文件????????2158??2013-02-27?21:17??BluetoothChat\res\layout\device_list.xm
?????文件?????????876??2013-02-27?21:17??BluetoothChat\res\layout\device_name.xm
?????文件????????1744??2013-02-27?21:17??BluetoothChat\res\layout\main.xm
?????文件?????????876??2013-02-27?21:17??BluetoothChat\res\layout\message.xm
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\res\menu\
?????文件????????1364??2013-02-27?21:17??BluetoothChat\res\menu\option_menu.xm
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\res\values\
?????文件????????1976??2013-02-27?21:17??BluetoothChat\res\values\strings.xm
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\src\
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\src\com\
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\src\com\example\
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\src\com\example\android\
?????目錄???????????0??2013-03-29?15:56??BluetoothChat\src\com\example\android\BluetoothChat\
?????文件???????13775??2013-02-27?21:17??BluetoothChat\src\com\example\android\BluetoothChat\BluetoothChat.java
?????文件???????17971??2013-02-27?21:17??BluetoothChat\src\com\example\android\BluetoothChat\BluetoothChatService.java
?????文件????????7959??2013-02-27?21:17??BluetoothChat\src\com\example\android\BluetoothChat\DeviceListActivity.java
- 上一篇:Java在線編輯編譯運行
- 下一篇:SCAN社團發現算法
評論
共有 條評論