TedImagePicker icon indicating copy to clipboard operation
TedImagePicker copied to clipboard

Scoped Stoarge Android 11

Open Sayed-Shalan opened this issue 5 years ago • 3 comments
trafficstars

Hello, Does this lib implements migration to Scoped storage for Android 10 & 11 ?. Thanks you.

Sayed-Shalan avatar Jun 30 '20 22:06 Sayed-Shalan

hello , did you find a solution for this ?

mohamedsaad1994 avatar Aug 21 '20 14:08 mohamedsaad1994

hey,I think this issue should be addressed now that google is enforcing use of scoped storage. Allowing legacy requests will not be working anymore.

ndungudedan avatar Apr 20 '21 10:04 ndungudedan

Try to update to the latest version

implementation 'io.github.ParkSangGwon:tedimagepicker:1.2.7' Then use the following lines of code. Checking if android is >10 and getting the Uri as follows sorted the issue

TedImagePicker.with(this)
.errorListener(new OnErrorListener() {
@OverRide
public void onError(@nonnull Throwable throwable) {
Timber.e(throwable.getMessage());
}
})
.mediaType(MediaType.IMAGE)
.start(uri -> {
File file = new File(uri.getPath());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
String[] filePathColumn = {MediaStore.MediaColumns.DATA};
Cursor cursor = App.getContext().getContentResolver().query(
uri,
filePathColumn,
null,
null,
null);
if (cursor != null) {
if (cursor.moveToFirst()) {
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String absolutePathOfImage = cursor.getString(columnIndex);
if (absolutePathOfImage != null) {
Uri.parse(absolutePathOfImage);
file = new File(absolutePathOfImage);
}
cursor.close();
}
}
}
});

ndungudedan avatar Jan 17 '22 14:01 ndungudedan