Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.net.Uri;
import android.os.Environment;

import java.io.File;

import java.io.IOException;

public class Main {
    /**
     * Get Image Uri when clicked from Camera
     *
     * @return Uri of clicked Image
     */
    public static Uri getBitmapUri() {
        File imageStorageDir = new File(
                Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "CRMnextImages");
        if (!imageStorageDir.exists()) {
            imageStorageDir.mkdirs();
        }
        File file = null;
        try {
            file = File.createTempFile("IMG_" + String.valueOf(System.currentTimeMillis()), ".jpg",
                    imageStorageDir);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return Uri.fromFile(file);
    }
}