Import Pictures from Picasa in Motorola Xoom
I have written a simple code for importing images from any image-supported applications
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE);
The code works fine when importing images from gallery but as soon as i import image from the picasa in my motorola xoom. It returns null and force closes with NullPointerExcep开发者_JAVA技巧tion
.
Does anybody have any idea about this ?
ACTIVITYRESULT_CHOOSEPICTURE is the int you use when calling startActivity(intent, requestCode);
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == ACTIVITYRESULT_CHOOSEPICTURE) {
BitmapFactory.Options options = new BitmapFactory.Options();
final InputStream is = context.getContentResolver().openInputStream(intent.getData());
final Bitmap bitmap = BitmapFactory.decodeStream(is, null, options);
is.close();
}
精彩评论