Commit ca1f6fe4 authored by sivl0509's avatar sivl0509
Browse files

permission code not necessary to be done during the tutorial, mentioning it is sufficient

parent 4b3528fd
......@@ -20,6 +20,8 @@ class SessionActivity : AppCompatActivity() {
private lateinit var mBinding: SessionActivityBinding
private lateinit var mViewModel: SessionViewModel
private val mSensorPermissionRequestCode = 0
private val mBtnStartSessionId = "Start"
private val mBtnStopSessionId = "Stop"
......@@ -62,7 +64,20 @@ class SessionActivity : AppCompatActivity() {
}
private fun checkSensorPermissions() {
// TODO
var permissions: MutableList<String> = ArrayList()
if (ContextCompat.checkSelfPermission(
this,
Manifest.permission.BODY_SENSORS
) != PackageManager.PERMISSION_GRANTED
) {
permissions.add(Manifest.permission.BODY_SENSORS)
}
if (permissions.size > 0) {
// Sensor permission is not granted
requestSensorPermissions(permissions.toTypedArray())
}
}
private fun initUiElements() {
......@@ -84,13 +99,21 @@ class SessionActivity : AppCompatActivity() {
}
private fun requestSensorPermissions(permissions: Array<String>) {
// TODO
ActivityCompat.requestPermissions(
this,
permissions,
mSensorPermissionRequestCode
)
}
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String>, grantResults: IntArray
) {
// TODO
when (requestCode) {
mSensorPermissionRequestCode -> {
checkSensorPermissions()
}
}
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment