private fun askPermissions(){ Dexter.withContext(this) .withPermissions( Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION ) .withListener(object : MultiplePermissionsListener { override fun onPermissionsChecked(report: MultiplePermissionsReport?) { if (report!!.areAllPermissionsGranted()) { // TODO (STEP 7: Call the location request function here.) } if (report.isAnyPermissionPermanentlyDenied) { Toast.makeText( this@MainActivity, "You have denied location permission. Please allow it is mandatory.", Toast.LENGTH_SHORT ).show() } } override fun onPermissionRationaleShouldBeShown( permissions: MutableList<PermissionRequest>?, token: PermissionToken? ) { showRationalDialogForPermissions() } }).onSameThread() .check() }