资源简介

android 蓝牙助手 源代码

资源截图

代码片段和文件信息

/*
 * The MIT License (MIT)

 * Copyright (c) 2015 linkMob.cc

 * Author: lujun

 * Permission is hereby granted free of charge to any person obtaining a copy
 * of this software and associated documentation files (the “Software“) to deal
 * in the Software without restriction including without limitation the rights
 * to use copy modify merge publish distribute sublicense and/or sell
 * copies of the Software and to permit persons to whom the Software is
 * furnished to do so subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
 * IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER
 * LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package co.lujun.lmbluetoothsdk;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;

import java.util.Set;
import java.util.UUID;

import co.lujun.lmbluetoothsdk.base.Bluetooth;
import co.lujun.lmbluetoothsdk.base.BluetoothListener;
import co.lujun.lmbluetoothsdk.base.State;
import co.lujun.lmbluetoothsdk.service.BluetoothService;

/**
 * Author: lujun(http://blog.lujun.co)
 * Date: 2016-1-14 10:59
 */
public class BluetoothController extends Bluetooth {

    private BluetoothService mBluetoothService;

    private static BluetoothController sBluetoothController;

    /**
     * Get current instance as singleton.
     * @return BluetoothController instance
     */
    public static BluetoothController getInstance(){
        if (sBluetoothController == null){
            synchronized (BluetoothController.class){
                if (sBluetoothController == null){
                    sBluetoothController = new BluetoothController();
                }
            }
        }
        return sBluetoothController;
    }

    /**
     * Build this instance.
     * @param context the current context you use
     * @return BluetoothController instance
     */
    public BluetoothController build(Context context){
        mContext = context;
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        mBluetoothService = new BluetoothService();
        return this;
    }

    /**
     * Set bluetooth listener you can check all bluetooth status and read data with this listener‘s callback.
     * @param listener a BluetoothListener
     */
    public void setBluetoothListener(BluetoothListener listener){
        this.mBluetoothListener = listener;
        registerReceiver();
        if (mBluetoothService != null) {
  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\
     文件         511  2017-02-16 13:58  LMBluetoothSdk-master\.gitignore
     文件         684  2017-02-16 13:58  LMBluetoothSdk-master\.travis.yml
     文件        9556  2017-02-16 13:58  LMBluetoothSdk-master\README.md
     文件         644  2017-02-16 13:58  LMBluetoothSdk-master\build.gradle
     文件         855  2017-02-16 13:58  LMBluetoothSdk-master\gradle.properties
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\gradle\
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\gradle\wrapper\
     文件       53637  2017-02-16 13:58  LMBluetoothSdk-master\gradle\wrapper\gradle-wrapper.jar
     文件         233  2017-02-16 13:58  LMBluetoothSdk-master\gradle\wrapper\gradle-wrapper.properties
     文件        4971  2017-02-16 13:58  LMBluetoothSdk-master\gradlew
     文件        2314  2017-02-16 13:58  LMBluetoothSdk-master\gradlew.bat
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\
     文件         511  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\.gitignore
     文件         559  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\build.gradle
     文件         685  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\proguard-rules.pro
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\
     文件         336  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\AndroidManifest.xml
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\lujun\
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\lujun\lmbluetoothsdk\
     文件        6370  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\lujun\lmbluetoothsdk\BluetoothController.java
     文件       10355  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\lujun\lmbluetoothsdk\BluetoothLEController.java
     目录           0  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\lujun\lmbluetoothsdk\base\
     文件        3026  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\lujun\lmbluetoothsdk\base\baseListener.java
     文件        7282  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\lujun\lmbluetoothsdk\base\Bluetooth.java
     文件        2451  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\lujun\lmbluetoothsdk\base\BluetoothLEListener.java
     文件        1588  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\lujun\lmbluetoothsdk\base\BluetoothListener.java
     文件        1900  2017-02-16 13:58  LMBluetoothSdk-master\lmbluetoothsdk\src\main\java\co\lujun\lmbluetoothsdk\base\State.java
............此处省略69个文件信息

评论

共有 条评论