Meine App verfügt über die Möglichkeit, ein Foto aus der Bibliothek auszuwählen. Genau ich möchte Dateipfad von dieser Auswahl.Die Auswahl des Fotos mit der neuen Google Fotos-App ist fehlerhaft
Dies ist der Code Absicht zur Auswahl Foto zu erstellen:
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, INTENT_REQUEST_CODE_SELECT_PHOTO);
Dies ist der Code, den Dateipfad von URI bekommt:
Cursor cursor = null;
String path = null;
try {
String[] projection = { MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, projection, null, null, null);
int columnIndex = cursor.getColumnIndexOrThrow(projection[0]);
cursor.moveToFirst();
path = cursor.getString(columnIndex);
} finally {
if (cursor != null) {
cursor.close();
}
}
return path;
Vor update gestern von Google Fotos perfekt funktioniert alles App fein. Jetzt path
ist Null nach dem Parsing URI.
URI ist ähnlich wie folgt aus: content://com.google.android.apps.photos.contentprovider/0/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F75209/ACTUAL
ich auch Absicht mit Intent.ACTION_GET_CONTENT Aktion zu schaffen versucht - kein Glück. Diese
Ich habe diese Antwort akzeptiert, obwohl für unseren Flow ist dies ein bisschen eine Ausweichlösung. Aber es erlaubt, die App zurück in den voll funktionsfähigen Zustand zu bringen, das zählt. Eine Anmerkung: Ich habe keine Bitmap-Decodierung von einem InputStream gemacht - ich habe es in eine Datei 'tempFile = new File (" path_to_my_temp_directory ") kopiert;' und dann die letzte für all das Zeug benutzt. –
@Akhil Danke dafür! – Petro
'ist = context.getContentResolver(). OpenInputStream (uri);' gibt null zurück. Ich kann anscheinend keine Lösung finden, um Bilder von der Google Fotos App auszuwählen. Wenn jemand eine funktionierende Lösung hat, bitte teilen. – ArJ