The First Line of Code by Lin Guo

The First Line of Code by Lin Guo

Author:Lin Guo
Language: eng
Format: epub
ISBN: 9789811918001
Publisher: Springer Nature Singapore


The error message said Permission Denial, and this is because we have to treat dangerous permission as runtime permissions for Android 6.0 and above.

Let us try to fix this problem by updating MainActivity as code below: class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)

setContentView(R.layout.activity_main)

makeCall.setOnClickListener {

if (ContextCompat.checkSelfPermission(this,

Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {

ActivityCompat.requestPermissions(this,

arrayOf(Manifest.permission.CALL_PHONE), 1)

} else {

call()

}

}

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.