Open RageshAntony opened 3 years ago
thanks for your reply, I mean is when clicking on the icon "take photo" can't work on Android 11, Android 10 is ok. Do you check on Android 11?
thanks for your reply, I mean is when clicking on the icon "take photo" can't work on Android 11, Android 10 is ok.
I check only in Android 10 . Not working in 10 but working in 9
hi all, I updated the lib, not using permission WRITE, it worked very well for me, some update in mine:
update dispatchTakePictureIntent function fun dispatchTakePictureIntent(): Intent? { val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) // Ensure that there's a camera activity to handle the intent if (Build.VERSION.SDK_INT >=29) { filephoto = getImageFile(File(mContext.getFilesDir(), "filepicker")) val authority = mContext.packageName + mContext.getString(R.string.image_picker_provider_authority_suffix) photoURI = FileProvider.getUriForFile(mContext, authority, filephoto!!) takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI) return takePictureIntent
} else {
if (takePictureIntent.resolveActivity(mContext.packageManager) != null) {
// Create the File where the photo should go
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
filephoto = getImageFile(File(mContext.getFilesDir(), "filepicker"))
val authority =
mContext.packageName + mContext.getString(R.string.image_picker_provider_authority_suffix)
photoURI = FileProvider.getUriForFile(mContext, authority, filephoto!!)
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI)
} else {
filephoto = getImageFile(File(mContext.getExternalCacheDir(), "filepicker"))
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(filephoto))
}
return takePictureIntent
}
}
return null
}
// get all photo in the internal memory
var arrayList = ArrayList
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N) {
file = File(activity?.getExternalCacheDir(), "filepicker")
} else {
file = File(activity?.filesDir, "filepicker")
}
if (file != null && file.isDirectory!!) {
val children = file.listFiles()
Arrays.sort(children
) { o1, o2 -> java.lang.Long.compare(o1?.lastModified()!!, o2?.lastModified()!!) }
var index = 0
for (pathString in children) {
if (pathString.name.lastIndexOf(".jpg") > 0) {
if (!checkExist(arrayList, pathString.name)) {
val filePhoto = File(file.absolutePath + "/" + pathString.name)
if (filePhoto.length() > 0) {
val media = Media(
0,
getFileName(pathString.name),
Uri.fromFile(filePhoto),
1
)
arrayList.add(index, media)
}
}
}
}
mCurrentMedias = arrayList.toMutableList().toList()
}
here is the lib I updated, worked very well in my project filepicker.zip
in Android 10 (ONE UI 2) , it's showing placeholder images even though requestLegacyExternalStorage = "true" ? I am using latest 2.2.5
My manifest
FilePicker call :
Result
Please help me