Created
September 5, 2017 02:09
-
-
Save maxost/bd2121c8306a4deae5a9dce1098f889e to your computer and use it in GitHub Desktop.
Kotlin: make phone call in Android
This file contains hidden or 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
fun Context.makePhoneCall(number: String) : Boolean { | |
try { | |
val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:$number")) | |
startActivity(intent) | |
return true | |
} catch (e: Exception) { | |
e.printStackTrace() | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
private fun checkPermission() {
if (ContextCompat.checkSelfPermission(requireActivity(),
Manifest.permission.CALL_PHONE)
!= PackageManager.PERMISSION_GRANTED) {