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 java.io.File;

import java.io.IOException;

import android.content.Context;

import android.media.ExifInterface;
import android.net.Uri;

import android.util.Log;

public class Main {
    private static int getOrientationFromExif(Uri imageUri, Context context) {
        int orientation = -1;
        Log.i("Photo Editor", "imageUri = " + imageUri);
        // File imageFile = new File(getRealPathFromUri(imageUri, context));
        File imageFile = new File(imageUri.getPath());
        try {
            ExifInterface exif;
            Log.i("Photo Editor", "imageFile.getAbsolutePath() = " + imageFile.getAbsolutePath());
            exif = new ExifInterface(imageFile.getAbsolutePath());
            orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return orientation;
    }
}