diff --git a/README.md b/README.md
index 23e00de..4f32a0c 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ Including BLE, TCP/IP, Bound Witnessing, and Bridging. Use this instead of `sdk
## Gradle Build
```gradle
- compile 'network.xyo:sdk-xyo-android:3.1.34'
+ compile 'network.xyo:sdk-xyo-android:3.1.38'
```
## Maven Build
@@ -41,7 +41,7 @@ Including BLE, TCP/IP, Bound Witnessing, and Bridging. Use this instead of `sdk
network.xyo
sdk-xyo-android
- 3.1.34
+ 3.1.38
pom
diff --git a/xyo-android-library/build.gradle b/xyo-android-library/build.gradle
index 64c1177..e3dd60a 100644
--- a/xyo-android-library/build.gradle
+++ b/xyo-android-library/build.gradle
@@ -52,7 +52,7 @@ task printVersion {
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
- ndkVersion "21.0.6113669"
+ ndkVersion "21.1.6352462"
versionProps['VERSION_PATCH'] = patch.toString()
versionProps.store(versionPropsFile.newWriter(), null)
diff --git a/xyo-android-library/version.properties b/xyo-android-library/version.properties
index fd52212..8f5bcb7 100644
--- a/xyo-android-library/version.properties
+++ b/xyo-android-library/version.properties
@@ -1,2 +1,2 @@
-#Thu May 07 04:42:24 UTC 2020
-VERSION_PATCH=36
+#Fri May 15 16:08:25 UTC 2020
+VERSION_PATCH=38
diff --git a/xyo-android-sample/build.gradle b/xyo-android-sample/build.gradle
index af57677..778b5c4 100644
--- a/xyo-android-sample/build.gradle
+++ b/xyo-android-sample/build.gradle
@@ -7,7 +7,7 @@ apply plugin: 'maven-publish'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
- ndkVersion "21.0.6113669"
+ ndkVersion "21.1.6352462"
defaultConfig {
applicationId "network.xyo.sdk.sample"
minSdkVersion 21
diff --git a/xyo-android-sample/src/main/java/network/xyo/sdk/sample/MainActivity.kt b/xyo-android-sample/src/main/java/network/xyo/sdk/sample/MainActivity.kt
index 3a02a31..f71e12d 100644
--- a/xyo-android-sample/src/main/java/network/xyo/sdk/sample/MainActivity.kt
+++ b/xyo-android-sample/src/main/java/network/xyo/sdk/sample/MainActivity.kt
@@ -1,5 +1,6 @@
package network.xyo.sdk.sample
+import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import android.location.LocationManager
@@ -7,6 +8,7 @@ import android.util.Log
import android.os.Bundle
import com.google.android.material.bottomnavigation.BottomNavigationView
import androidx.appcompat.app.AppCompatActivity
+import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
@@ -23,31 +25,66 @@ import network.xyo.sdkobjectmodelkotlin.structure.XyoIterableStructure
@kotlin.ExperimentalUnsignedTypes
class MainActivity : AppCompatActivity() {
-
lateinit var node: XyoNode
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- GlobalScope.launch {
-// initializeXyoSimpleWithGps()
- //initializeXyoSimple()
-// initializeXyoBleClientOnly()
- //initializeXyoBleServerOnly()
- initializeXyoBleOnly()
- ui {
- setContentView(R.layout.activity_main)
- val navView: BottomNavigationView = findViewById(R.id.nav_view)
-
- val navController = findNavController(R.id.nav_host_fragment)
- // Passing each menu ID as a set of Ids because each
- // menu should be considered as top level destinations.
- val appBarConfiguration = AppBarConfiguration(
- setOf(
- R.id.navigation_ble_client, R.id.navigation_ble_server, R.id.navigation_tcpip_client, R.id.navigation_tcpip_server
- )
+
+ checkPermissions()
+ }
+
+ private fun checkPermissions () {
+ // check if we already have the permission
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
+ == PackageManager.PERMISSION_GRANTED) {
+
+ // if we do, continue the setup process
+ setupNodeAndUI()
+ return
+ }
+
+ // if we do not, request the permission
+ ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), 1)
+ }
+
+
+ // this gets called when the user takes action on a permission request
+ override fun onRequestPermissionsResult(
+ requestCode: Int,
+ permissions: Array,
+ grantResults: IntArray
+ ) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+
+ if (requestCode != 1) {
+ return
+ }
+
+ // recheck the permissions
+ checkPermissions()
+ }
+
+ private fun setupNodeAndUI () = GlobalScope.launch {
+ // initializeXyoSimpleWithGps()
+ // initializeXyoSimple()
+ // initializeXyoBleClientOnly()
+ // initializeXyoBleServerOnly()
+ initializeXyoBleOnly()
+ ui {
+
+ setContentView(R.layout.activity_main)
+ val navView: BottomNavigationView = findViewById(R.id.nav_view)
+
+ val navController = findNavController(R.id.nav_host_fragment)
+ // Passing each menu ID as a set of Ids because each
+ // menu should be considered as top level destinations.
+ val appBarConfiguration = AppBarConfiguration(
+ setOf(
+ R.id.navigation_ble_client, R.id.navigation_ble_server, R.id.navigation_tcpip_client, R.id.navigation_tcpip_server
)
- setupActionBarWithNavController(navController, appBarConfiguration)
- navView.setupWithNavController(navController)
- }
+ )
+ setupActionBarWithNavController(navController, appBarConfiguration)
+ navView.setupWithNavController(navController)
}
}