This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.siddroid.folding | |
fun main() { | |
// Composing our car | |
val car = Car.compose(Chain.carEngineType(EngineType.ELECTRIC) | |
.carOwnerDetails(name = "Android Dev Community", | |
licenceNo = "API31", | |
address = "California" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-permission android:name="android.permission.READ_CONTACTS"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onRequestPermissionsResult( | |
requestCode: Int, | |
permissions: Array<out String>, | |
grantResults: IntArray | |
) { | |
when (requestCode) { | |
REQUEST_CONTACTS_STATE -> { | |
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
Toast.makeText(this, "Permission granted", Toast.LENGTH_SHORT).show() | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<string name="rationale_title">We need permission to read your contacts</string> | |
<string name="rationale_desc">This app relies on read access to your contacts. We require access to this permission to find your contacts in our database and suggest people you may know. We will not store any contact info in our data base if they are not a part of our platform. For further info read our privacy policy.</string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks permission, if permission has been denied shows rationale for the permission | |
*/ | |
private fun checkContactsPermission() { | |
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_CONTACTS) | |
!= PackageManager.PERMISSION_GRANTED | |
) { | |
// Check if permission is not granted | |
Log.d(TAG, "Permission for contacts is not granted") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Shows rationale dialog for displaying why the app needs permission | |
* Only shown if the user has denied the permission request previously | |
*/ | |
private fun showRationaleDialog( | |
title: String, | |
message: String, | |
permission: String, | |
requestCode: Int | |
) { |