Choose picture Intent causes nullpointer exception

后端 未结 3 621
一生所求
一生所求 2020-12-19 16:48
 public void uploadpicture(View view)
        {
            Intent intent = new Intent();
            intent.setType(\"image/*\");
            intent.setAction(Inten         


        
3条回答
  •  执念已碎
    2020-12-19 17:28

    From your log it looks like you are trying to pick an image from Picasa folder dat=content://com.android.sec.gallery3d.provider/picasa/item/5147009501910019474, and these must be handled differently, because data in MediaStore.Images.Media.DATA column will be null for them. You can see how to handle picking images from Picasa correctly at this link:

    http://dimitar.me/how-to-get-picasa-images-using-the-image-picker-on-android-devices-running-any-os-version/

    Only you also need to handle URIs that start with "content://com.sec.android.gallery3d" (I see this on Samsung S3) so change

    if (selectedImage.toString().startsWith("content://com.google.android.gallery3d"))
    

    to

    if (_selectedImage.toString().startsWith("content://com.google.android.gallery3d") 
        || selectedImage.toString().startsWith("content://com.sec.android.gallery3d"))
    

    I'm not sure if there are any more special cases (probably yes).

提交回复
热议问题