Permissions
If you want to read a document from the gallery, you need to make sure that your application has permission to read from external storage. You can check it using the following code:
// checking for image browsing permissions
if (ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
} else {
// start image browsing
createImageBrowsingRequest();
}
// checking for image browsing permissions
if (ContextCompat.checkSelfPermission(this@MainActivity,
Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this@MainActivity,
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE
} else {
// start image browsing
createImageBrowsingRequest()
}
In order to use NFC, you should include the following permission to the Android Manifest:
android.permission.NFC