mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-16 00:11:03 +08:00
Guard against null pointer exception in ES File Explorer being used to get a picture
This commit is contained in:
parent
54caa6e438
commit
1b4096b01d
@ -1048,10 +1048,16 @@ public class FileUtils extends Plugin {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
protected static String getRealPathFromURI(Uri contentUri, CordovaInterface cordova) {
|
protected static String getRealPathFromURI(Uri contentUri, CordovaInterface cordova) {
|
||||||
String[] proj = { _DATA };
|
String uri = contentUri.toString();
|
||||||
Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null, null);
|
if (uri.startsWith("content:")) {
|
||||||
int column_index = cursor.getColumnIndexOrThrow(_DATA);
|
String[] proj = { _DATA };
|
||||||
cursor.moveToFirst();
|
Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null, null);
|
||||||
return cursor.getString(column_index);
|
int column_index = cursor.getColumnIndexOrThrow(_DATA);
|
||||||
|
cursor.moveToFirst();
|
||||||
|
return cursor.getString(column_index);
|
||||||
|
} else {
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user