Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Intent;

import android.net.Uri;

public class Main {
    public static Uri handleChoosenImage(Intent data, Uri fileUri) {
        final boolean isCamera;
        if (data == null) {
            isCamera = true;
        } else {
            final String action = data.getAction();
            if (action == null) {
                isCamera = false;
            } else {
                isCamera = action.equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            }
        }

        Uri selectedImageUri;
        if (isCamera) {
            selectedImageUri = fileUri;
        } else {
            selectedImageUri = data == null ? null : data.getData();
        }

        return selectedImageUri;
    }
}