I choose from the android device file and i got uri that start with "content://com.google.android.app" and for some reason i can't make load it into bitmap,
the code
public void insertImage(View view) {
Intent chooseFile;
Intent intent;
chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
chooseFile.setType("*/*");
chooseFile.addCategory(Intent.CATEGORY_OPENABLE);
intent = Intent.createChooser(chooseFile, "Choose a file");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, PICKFILE_RESULT_CODE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case PICKFILE_RESULT_CODE:
if (resultCode == RESULT_OK) {
Uri uri = data.getData();
String str = data.getData().toString();
String mimeType = getContentResolver().getType(uri);
try {
// User content resolver to get uri input stream.
InputStream inputStream =
getContentResolver().openInputStream(uri);
// Get the bitmap.
Bitmap imgBitmap = BitmapFactory.decodeStream(inputStream);
// Show image bitmap in imageview object.
imageView.setImageBitmap(imgBitmap);
}catch(FileNotFoundException ex)
{
Log.e(TAG, ex.getMessage(), ex);
}
}
break;
}
}
any ideas?