private fun clickPhoto(){
Intent(MediaStore.ACTION_IMAGE_CAPTURE).also { takePictureIntent ->
takePictureIntent.resolveActivity(requireActivity().packageManager)?.also {
val photoFile: File? = try {
createFile(requireActivity(), Environment.DIRECTORY_PICTURES, "jpg")
} catch (ex: IOException) {
Toast.makeText(requireActivity(), getString(R.string.create_file_Error, ex.message),
Toast.LENGTH_SHORT).show()
null
}
photoFile?.also {
selectedPhotoPath = it.absolutePath
val photoURI: Uri = FileProvider.getUriForFile(
requireActivity(),
BuildConfig.APPLICATION_ID + ".fileprovider",
it
)
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI)
startActivityForResult(takePictureIntent, CAMERA_PHOTO_REQUEST)
}
}
}
}
This is my click photo function where resolveActivity() gives a warning Consider adding a <queries> declaration to your manifest when calling this method; see https://g.co/dev/packagevisibility for details
.I know that since API 30 we need queries to access the information of other installed apps.
I also know that this can be resolved by not using resolveActivity() but i want to learn how to add queries to manifest.
This is my manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.akaalistudios.employeemanagement">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.EmployeeManagement">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
</application>
</manifest>