资源简介
BluetoothChat 蓝牙聊天 Android 官方源码 带注释 只用了3个java文件实行了蓝牙聊天,代码简单易懂
代码片段和文件信息
/*
* 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.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 = 1;
private static final int REQUEST_ENABLE_BT = 2;
// Layout Views
private TextView mtitle;
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) {
super.onCreate(savedInstanceState);
if(D) Log.e(TAG “+++ ON CREAT
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1799 2010-08-08 15:20 BluetoothChat\BluetoothChat\AndroidManifest.xm
文件 4182 2010-08-08 15:20 BluetoothChat\BluetoothChat\res\drawable\app_icon.png
文件 5589 2010-08-08 15:20 BluetoothChat\BluetoothChat\res\drawable-hdpi\app_icon.png
文件 1532 2010-08-08 15:20 BluetoothChat\BluetoothChat\res\layout\custom_ti
文件 2158 2010-08-08 15:20 BluetoothChat\BluetoothChat\res\layout\device_list.xm
文件 876 2010-08-08 15:20 BluetoothChat\BluetoothChat\res\layout\device_name.xm
文件 1744 2010-08-08 15:20 BluetoothChat\BluetoothChat\res\layout\main.xm
文件 876 2010-08-08 15:20 BluetoothChat\BluetoothChat\res\layout\message.xm
文件 1033 2010-08-08 15:20 BluetoothChat\BluetoothChat\res\menu\option_menu.xm
文件 1793 2010-08-08 15:20 BluetoothChat\BluetoothChat\res\values\strings.xm
文件 13147 2010-08-08 15:20 BluetoothChat\BluetoothChat\src\com\example\android\BluetoothChat\BluetoothChat.java
文件 15570 2010-08-08 15:20 BluetoothChat\BluetoothChat\src\com\example\android\BluetoothChat\BluetoothChatService.java
文件 7958 2010-08-08 15:20 BluetoothChat\BluetoothChat\src\com\example\android\BluetoothChat\DeviceListActivity.java
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\src\com\example\android\BluetoothChat
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\src\com\example\android
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\src\com\example
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\res\drawable
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\res\drawable-hdpi
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\res\layout
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\res\menu
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\res\values
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\src\com
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\res
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat\src
目录 0 2010-11-30 18:34 BluetoothChat\BluetoothChat
目录 0 2010-11-30 18:34 BluetoothChat
----------- --------- ---------- ----- ----
58257 26
- 上一篇:JSP页面设计表格
- 下一篇:Java秒杀系统方案全套视频.zip
相关资源
- unity 捕捉异常和移动设备崩溃Android
- android欢迎界面源码
- android5.1_root_patch
- Android WebView实现视频全屏
- android仿QQ锁屏源码
- Android调用WPS
- android SQLite数据库的增删改
- android-support-v7-appcompat绿色版
- Android撒花效果
- android版简单贪吃蛇小游戏代码
- Android DropDownMenu下拉菜单
- android 二级城市选择
- Android 最简单的GPS获取源代码
- android的显示gif图片的demo
- Android开发之拍照功能实现
- Android小游戏源代码-沙漠狙击手源代码
- Android获取手机联系人信息
- android连连看游戏源代码加入8种关卡设
- eclipse 计算器 Android
- Android五种布局
- Android静默拍照
- Android使用OkHttp访问自签名证书的接口
- android底部凸起导航菜单
- Android程序Crash时的异常上传
- Android端websocket调用(含autobahn-0.5.0.
- Android检测用户心率应用源码
- Linux Audio for Android
- android下的猜数字游戏源码,详尽注释
- Android中实现WebView点击图片放大显示
- Android获取短信验证码倒计时按钮
评论
共有 条评论