gain Image Uri from Intent - Android Graphics

Android examples for Graphics:Image Download

Description

gain Image Uri from Intent

Demo Code


import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore;

public class Main{
    /*  w w w  .  ja  v a 2 s . c  o m*/
    public static final int REQUEST_CODE_TAKE_PHOTO = 0xF1;
    
    public static final int REQUEST_CODE_PICK_PHOTO = REQUEST_CODE_TAKE_PHOTO + 3;
    
    public static final int REQUEST_CODE_CROP = REQUEST_CODE_TAKE_PHOTO + 5;
    public static Uri gainImageUri(int requestCode, Intent data, Uri takeUri) {
        Uri photoUri = null;
        if (requestCode == CameraUtil.REQUEST_CODE_TAKE_PHOTO) {
            if (data != null) {
                photoUri = data.getData();
            }
            if (photoUri == null) {
                photoUri = takeUri;
            }
        } else if (requestCode == CameraUtil.REQUEST_CODE_PICK_PHOTO) {
            if (data != null) {
                photoUri = data.getData();
            }
        } else if (requestCode == CameraUtil.REQUEST_CODE_CROP) {
        }
        return photoUri;
    }
}

Related Tutorials