├── .github └── logo.png ├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── sirvar │ │ └── bluetoothkit │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── sirvar │ │ │ └── bluetoothkit │ │ │ └── MainActivity.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.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 │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── sirvar │ └── bluetoothkit │ └── ExampleUnitTest.kt ├── bluetoothkit ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── sirvar │ │ └── bluetoothkit │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── sirvar │ │ └── bluetoothkit │ │ ├── BluetoothKit.kt │ │ ├── BluetoothKitSecuredSocket.kt │ │ ├── BluetoothKitSocket.kt │ │ └── BluetoothKitSocketInterface.kt │ └── test │ └── java │ └── com │ └── sirvar │ └── bluetoothkit │ └── ExampleUnitTest.java ├── build.gradle ├── docs ├── alltypes │ └── index.html ├── com.sirvar.bluetoothkit │ ├── -bluetooth-kit-secured-socket │ │ ├── -init-.html │ │ ├── close.html │ │ ├── connect.html │ │ ├── index.html │ │ ├── input-stream.html │ │ └── output-stream.html │ ├── -bluetooth-kit-socket-interface │ │ ├── close.html │ │ ├── connect.html │ │ ├── device-address.html │ │ ├── device-name.html │ │ ├── index.html │ │ ├── input-stream.html │ │ ├── output-stream.html │ │ └── socket.html │ ├── -bluetooth-kit-socket │ │ ├── -init-.html │ │ ├── close.html │ │ ├── connect.html │ │ ├── device-address.html │ │ ├── device-name.html │ │ ├── index.html │ │ ├── input-stream.html │ │ ├── output-stream.html │ │ └── socket.html │ ├── -bluetooth-kit │ │ ├── -init-.html │ │ ├── connect.html │ │ ├── disable.html │ │ ├── disconnect.html │ │ ├── enable.html │ │ ├── get-bluetooth-adapter.html │ │ ├── get-bluetooth-socket.html │ │ ├── get-device-by-address.html │ │ ├── get-device-by-name.html │ │ ├── get-paired-devices.html │ │ ├── index.html │ │ └── is-enabled.html │ └── index.html ├── index-outline.html ├── index.html └── style.css ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.github/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/4fc8c592071bdb1d4f9369e2642785a6409df7a8/.github/logo.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 47 | #*.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md.idea 66 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Rikin Katyal 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | Android Arsenal 5 | JitPack 6 | License MIT 7 |

8 | 9 | BluetoothKit is an incredibly **lightweight** and **simple** open source library to interface with Bluetooth devices on Android. 10 | 11 | ## Setup 12 | Add this to your `build.gradle` 13 | ```gradle 14 | allprojects { 15 | repositories { 16 | ... 17 | maven { url 'https://jitpack.io' } 18 | } 19 | } 20 | ``` 21 | then add the dependency 22 | ```gradle 23 | dependencies { 24 | implementation 'com.github.sirvar:bluetoothkit-android:v0.3' 25 | } 26 | ``` 27 | Alternatively, you can add this to maven 28 | ```xml 29 | 30 | 31 | jitpack.io 32 | https://jitpack.io 33 | 34 | 35 | ``` 36 | and add the dependency 37 | ```xml 38 | 39 | com.github.sirvar 40 | bluetoothkit-android 41 | 0.3 42 | 43 | 44 | ``` 45 | ## Usage 46 | 47 | ### Initialize 48 | ```kotlin 49 | val bluetoothKit = BluetoothKit() 50 | ``` 51 | 52 | ### Enable Bluetooth 53 | ```kotlin 54 | bluetoothKit.enable() 55 | ``` 56 | Alternatively, you may also do: 57 | ```kotlin 58 | bluetoothKit.isEnabled = true 59 | ``` 60 | ### Get Device 61 | ```kotlin 62 | val device = bluetoothKit.getDeviceByName("Rikin's AirPods") 63 | ``` 64 | ### Connect Device 65 | ```kotlin 66 | bluetoothKit.connect(device) 67 | ``` 68 | *That's it* 69 | 70 | ### Check out the complete docs [here](https://sirvar.github.io/bluetoothkit-android/com.sirvar.bluetoothkit/-bluetooth-kit/index.html) 71 | 72 | #### Apps currently using BluetoothKit: 73 | - https://play.google.com/store/apps/details?id=com.sirvar.quickconnect 74 | 75 | *If you're using BluetoothKit, feel free to make a PR and add it to the list* 76 | 77 | Made with ❤ by Rikin Katyal 78 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 28 9 | defaultConfig { 10 | applicationId "com.sirvar.bluetoothkit" 11 | minSdkVersion 15 12 | targetSdkVersion 28 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation project(":bluetoothkit") 27 | 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) 29 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 30 | implementation 'com.android.support:appcompat-v7:28.0.0' 31 | implementation 'com.android.support:recyclerview-v7:28.0.0' 32 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 33 | testImplementation 'junit:junit:4.12' 34 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 35 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 36 | } 37 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/sirvar/bluetoothkit/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.sirvar.bluetoothkit 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.sirvar.bluetoothkit", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/sirvar/bluetoothkit/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.sirvar.bluetoothkit 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | import kotlinx.android.synthetic.main.activity_main.* 6 | 7 | class MainActivity : AppCompatActivity() { 8 | 9 | companion object { 10 | private const val TAG = "MainActivity" 11 | } 12 | 13 | override fun onCreate(savedInstanceState: Bundle?) { 14 | super.onCreate(savedInstanceState) 15 | setContentView(R.layout.activity_main) 16 | 17 | val bluetoothKit = BluetoothKit() 18 | 19 | enable.setOnClickListener { bluetoothKit.enable() } 20 | disable.setOnClickListener { bluetoothKit.disable() } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |