开发者

Import Pictures from Picasa in Motorola Xoom

开发者 https://www.devze.com 2023-03-12 23:43 出处:网络
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

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();
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消