资源简介
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
相关资源
- Android非常漂亮的登录界面
- pc与android通过usb socket实现手机通信
- android毕业设计
- 百度地图自定义Markerandroid
- Android分区工具包
- android-support-v4.jar已打包进去源代码
- u-blox_Android_GNSS_Driver_v3.10驱动源码+中
- 个人根据Android移动开发案例详解手写
- android 视频播放器 项目和原码
- Android【动画】【特效】 17种动画特效
- 基于Android智能家居详细设计(经典)
- android通过JDBC连接Mysql数据库
- Android通讯录的源代码
- android 瀑布流Demo
- 指纹传感器FPC1080在android下的驱动
- delphi xe5 android 调用照相机摄像头拍照
- Android手机连连看游戏源码
- android-sdk-windows v2.3离线完整版
- android 底部弹出菜单(带透明背景)
- Android工程模式简介.rar
- Android蓝牙和Cors网络开发源码
- Android powermanger wakelock
- Android v7的一些jar包
- 最新android supportV7包
- android图片压缩工具类分享
- 单机搭建Android(解决Network is unreach
- Android上监听收到的短信(SMS)
- android电商app源码
- Android代码-多功能拨号盘源码.zip
- printershare直接破解版--11.5(适配andr
评论
共有 条评论