├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── layout │ │ │ ├── item_device.xml │ │ │ ├── activity_main.xml │ │ │ └── activity_ble.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── kongzue │ │ └── btlinker │ │ ├── MainActivity.java │ │ └── BLEActivity.java ├── proguard-rules.pro └── build.gradle ├── btutil ├── .gitignore ├── src │ └── main │ │ ├── res │ │ └── values │ │ │ └── strings.xml │ │ ├── java │ │ └── com │ │ │ └── kongzue │ │ │ └── btutil │ │ │ ├── interfaces │ │ │ ├── OnBLEReadListener.java │ │ │ ├── OnBLENotificationListener.java │ │ │ ├── OnBLEWriteListener.java │ │ │ ├── OnBtSocketResponseListener.java │ │ │ ├── OnDeviceLinkStatusChangeListener.java │ │ │ ├── BluetoothOpenListener.java │ │ │ ├── BtLinkReport.java │ │ │ ├── OnLinkStatusChangeListener.java │ │ │ ├── OnBLEFindServiceListener.java │ │ │ └── OnBLEScanListener.java │ │ │ ├── receiver │ │ │ └── BluetoothConnectActivityReceiver.java │ │ │ ├── util │ │ │ ├── TaskExecutor.java │ │ │ └── GattAttributes.java │ │ │ ├── SPPLinkUtil.java │ │ │ └── BLELinkUtil.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── dictionaries │ └── myzcx.xml ├── encodings.xml ├── markdown-navigator │ └── profiles_settings.xml ├── runConfigurations.xml ├── gradle.xml └── misc.xml ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /btutil/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':btutil' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BTLinker 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/dictionaries/myzcx.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /btutil/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BTUtil 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongzue/BTLinker/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches/build_file_checksums.ser 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | .DS_Store 9 | /build 10 | /captures 11 | .externalNativeBuild 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #008577 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/interfaces/OnBLEReadListener.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.interfaces; 2 | 3 | /** 4 | * Author: @Kongzue 5 | * Github: https://github.com/kongzue/ 6 | * Homepage: http://kongzue.com/ 7 | * Mail: myzcxhh@live.cn 8 | * CreateTime: 2019/1/9 20:48 9 | */ 10 | public interface OnBLEReadListener { 11 | void onReadMessage(String msg); 12 | } 13 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/interfaces/OnBLENotificationListener.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.interfaces; 2 | 3 | /** 4 | * Author: @Kongzue 5 | * Github: https://github.com/kongzue/ 6 | * Homepage: http://kongzue.com/ 7 | * Mail: myzcxhh@live.cn 8 | * CreateTime: 2019/1/9 23:27 9 | */ 10 | public interface OnBLENotificationListener { 11 | void onGetData(String data); 12 | } 13 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/interfaces/OnBLEWriteListener.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.interfaces; 2 | 3 | /** 4 | * Author: @Kongzue 5 | * Github: https://github.com/kongzue/ 6 | * Homepage: http://kongzue.com/ 7 | * Mail: myzcxhh@live.cn 8 | * CreateTime: 2019/1/9 21:15 9 | */ 10 | public interface OnBLEWriteListener { 11 | boolean onWrite(boolean isSuccess,String returnMsg); 12 | } 13 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/interfaces/OnBtSocketResponseListener.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.interfaces; 2 | 3 | /** 4 | * Author: @Kongzue 5 | * Github: https://github.com/kongzue/ 6 | * Homepage: http://kongzue.com/ 7 | * Mail: myzcxhh@live.cn 8 | * CreateTime: 2018/12/11 17:22 9 | */ 10 | public interface OnBtSocketResponseListener { 11 | 12 | void onResponse(String msg); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/interfaces/OnDeviceLinkStatusChangeListener.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.interfaces; 2 | 3 | /** 4 | * Author: @Kongzue 5 | * Github: https://github.com/kongzue/ 6 | * Homepage: http://kongzue.com/ 7 | * Mail: myzcxhh@live.cn 8 | * CreateTime: 2019/4/3 16:08 9 | */ 10 | public interface OnDeviceLinkStatusChangeListener { 11 | void onLinked(); 12 | 13 | void onLinkFailed(); 14 | } 15 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/interfaces/BluetoothOpenListener.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.interfaces; 2 | 3 | /** 4 | * Author: @Kongzue 5 | * Github: https://github.com/kongzue/ 6 | * Homepage: http://kongzue.com/ 7 | * Mail: myzcxhh@live.cn 8 | * CreateTime: 2019/3/27 16:36 9 | */ 10 | public interface BluetoothOpenListener { 11 | 12 | void onResponse(boolean isSuccess,int errorCode,String errorMsg); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/interfaces/BtLinkReport.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.interfaces; 2 | 3 | /** 4 | * Author: @Kongzue 5 | * Github: https://github.com/kongzue/ 6 | * Homepage: http://kongzue.com/ 7 | * Mail: myzcxhh@live.cn 8 | * CreateTime: 2018/9/2 16:44 9 | */ 10 | public interface BtLinkReport { 11 | void onStatusChange(String message); 12 | 13 | void onError(String message); 14 | 15 | void onGetData(String datas); 16 | } 17 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/interfaces/OnLinkStatusChangeListener.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.interfaces; 2 | 3 | /** 4 | * Author: @Kongzue 5 | * Github: https://github.com/kongzue/ 6 | * Homepage: http://kongzue.com/ 7 | * Mail: myzcxhh@live.cn 8 | * CreateTime: 2018/12/11 17:22 9 | */ 10 | public interface OnLinkStatusChangeListener { 11 | 12 | void onStartLink(); 13 | 14 | void onSuccess(); 15 | 16 | void onFailed(int errorCode); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/interfaces/OnBLEFindServiceListener.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.interfaces; 2 | 3 | import android.bluetooth.BluetoothGattService; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Author: @Kongzue 9 | * Github: https://github.com/kongzue/ 10 | * Homepage: http://kongzue.com/ 11 | * Mail: myzcxhh@live.cn 12 | * CreateTime: 2019/1/9 20:38 13 | */ 14 | public interface OnBLEFindServiceListener { 15 | 16 | void onLink(boolean isSuccess, List services); 17 | } 18 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /btutil/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/interfaces/OnBLEScanListener.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.interfaces; 2 | 3 | import android.bluetooth.BluetoothAdapter; 4 | import android.bluetooth.BluetoothDevice; 5 | import android.widget.ListView; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Author: @Kongzue 11 | * Github: https://github.com/kongzue/ 12 | * Homepage: http://kongzue.com/ 13 | * Mail: myzcxhh@live.cn 14 | * CreateTime: 2019/1/8 21:38 15 | */ 16 | public interface OnBLEScanListener { 17 | BluetoothDevice onFindDevice(BluetoothDevice device); 18 | 19 | void getAllDevice(List devices); 20 | 21 | void onStop(); 22 | } 23 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /btutil/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.kongzue.btlinker" 7 | minSdkVersion 19 8 | targetSdkVersion 28 9 | versionCode 2 10 | versionName "2.0" 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | } 19 | 20 | dependencies { 21 | implementation fileTree(include: ['*.jar'], dir: 'libs') 22 | implementation 'com.android.support:appcompat-v7:28.0.0' 23 | implementation 'com.kongzue.baseframework:baseframework:6.6.0' 24 | implementation project(':btutil') 25 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_device.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 23 | 24 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/receiver/BluetoothConnectActivityReceiver.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.receiver; 2 | 3 | import android.bluetooth.BluetoothDevice; 4 | import android.content.BroadcastReceiver; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | 8 | import com.kongzue.btutil.SPPLinkUtil; 9 | 10 | /** 11 | * Author: @Kongzue 12 | * Github: https://github.com/kongzue/ 13 | * Homepage: http://kongzue.com/ 14 | * Mail: myzcxhh@live.cn 15 | * CreateTime: 2018/9/2 23:01 16 | */ 17 | public class BluetoothConnectActivityReceiver extends BroadcastReceiver { 18 | 19 | @Override 20 | public void onReceive(Context context, Intent intent) { 21 | if (intent.getAction().equals("android.bluetooth.device.action.PAIRING_REQUEST")) { 22 | BluetoothDevice mBluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 23 | try { 24 | //(三星)4.3版本测试手机还是会弹出用户交互页面(闪一下),如果不注释掉下面这句页面不会取消但可以配对成功。(中兴,魅族4(Flyme 6))5.1版本手机两中情况下都正常 25 | //ClsUtils.setPairingConfirmation(mBluetoothDevice.getClass(), mBluetoothDevice, true); 26 | abortBroadcast();//如果没有将广播终止,则会出现一个一闪而过的配对框。 27 | //3.调用setPin方法进行配对... 28 | boolean ret = SPPLinkUtil.setPin(mBluetoothDevice.getClass(), mBluetoothDevice); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /btutil/src/main/java/com/kongzue/btutil/util/TaskExecutor.java: -------------------------------------------------------------------------------- 1 | package com.kongzue.btutil.util; 2 | 3 | import android.os.AsyncTask; 4 | import android.os.Handler; 5 | import android.os.Looper; 6 | 7 | import java.util.concurrent.Executor; 8 | 9 | import static android.os.AsyncTask.THREAD_POOL_EXECUTOR; 10 | 11 | /** 12 | * Created by LiuLei on 16/10/28. 13 | * Github: https://github.com/Alex-Jerry/Android-BLE 14 | */ 15 | public class TaskExecutor { 16 | 17 | private static Executor mParallelExecutor = AsyncTask.THREAD_POOL_EXECUTOR;//最多为5个线程 可以并发执行(也就是说最多只有5个线程同时运行,超过5个的就要等待) 异步线程池 18 | private static Executor mSerialExecutor = AsyncTask.SERIAL_EXECUTOR;//按照顺序执行 同步线程池(系统默认使用的) 19 | private static Handler sHandler = new Handler(Looper.getMainLooper()); 20 | 21 | private TaskExecutor() { 22 | mParallelExecutor = THREAD_POOL_EXECUTOR; 23 | mSerialExecutor = AsyncTask.SERIAL_EXECUTOR; 24 | } 25 | 26 | public static void runOnUIThread(Runnable runnable) { 27 | sHandler.post(runnable); 28 | } 29 | 30 | public static void executeTask(Runnable task) { 31 | executeTask(task, true); 32 | } 33 | 34 | public static void executeTaskSerially(Runnable task) { 35 | executeTask(task, false); 36 | } 37 | 38 | public static void executeTask(Runnable task, boolean parallel) { 39 | if (parallel) { 40 | mParallelExecutor.execute(task); 41 | return; 42 | } 43 | mSerialExecutor.execute(task); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /btutil/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | apply plugin: 'com.jfrog.bintray' 4 | 5 | def siteUrl = 'https://github.com/kongzue/BTLinker' //项目在github主页地址 6 | def gitUrl = 'https://github.com/kongzue/BTLinker.git' //Git仓库的地址 7 | 8 | group = "com.kongzue.smart"//发布aar前缀根节点 9 | version = "1.0.8"//发布aar的库版本 10 | 11 | android { 12 | compileSdkVersion 28 13 | 14 | defaultConfig { 15 | minSdkVersion 19 16 | targetSdkVersion 28 17 | versionCode 17 18 | versionName "1.0.8" 19 | } 20 | 21 | buildTypes { 22 | release { 23 | minifyEnabled false 24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 25 | } 26 | } 27 | 28 | lintOptions { 29 | abortOnError false 30 | } 31 | } 32 | install { 33 | repositories.mavenInstaller { 34 | // This generates POM.xml with proper parameters 35 | pom { 36 | project { 37 | packaging 'aar' 38 | name 'btlinker'//添加项目描述 39 | url siteUrl 40 | licenses { 41 | license { 42 | name 'The Apache Software License, Version 2.0' 43 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 44 | } 45 | } 46 | developers { 47 | developer { 48 | id 'myzchh'//设置自己ID 49 | name 'myzchh'//设置自己名字 50 | email 'myzcxhh@live.cn'//设置自己邮箱 51 | } 52 | } 53 | scm { 54 | connection gitUrl 55 | developerConnection gitUrl 56 | url siteUrl 57 | } 58 | } 59 | } 60 | } 61 | } 62 | task sourcesJar(type: Jar) { 63 | from android.sourceSets.main.java.srcDirs 64 | classifier = 'sources' 65 | } 66 | 67 | artifacts { 68 | archives sourcesJar 69 | } 70 | 71 | Properties properties = new Properties() 72 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 73 | bintray { 74 | user = properties.getProperty("bintray.user") 75 | key = properties.getProperty("bintray.apikey") 76 | configurations = ['archives'] 77 | pkg { 78 | repo = "maven" 79 | name = "BTLinker" //项目在JCenter的名字 80 | websiteUrl = siteUrl 81 | vcsUrl = gitUrl 82 | licenses = ["Apache-2.0"] 83 | publish = true 84 | } 85 | } 86 | dependencies { 87 | implementation fileTree(dir: 'libs', include: ['*.jar']) 88 | 89 | implementation 'com.android.support:appcompat-v7:28.0.0' 90 | } 91 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 20 | 21 | 30 | 31 | 35 | 36 | 41 | 42 | 46 | 47 | 52 | 53 |