CopyPastor

Detecting plagiarism made easy.

Score: 1.7513484954833984; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2016-06-10
by mdDroid

Original Post

Original - Posted on 2015-02-11
by the-ginger-geek



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Following code may help you
String path = FileUtility.getRealPathFromURI(context, Uri.parse(bitmapUri.getPath()); ExifInterface exif = new ExifInterface(path); rotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,ExifInterface.ORIENTATION_NORMAL);
FileUtility.java
public static String getRealPathFromURI(Context context, Uri contentUri) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return getPathForV19AndUp(context, contentUri); } else { return getPathForPreV19(context, contentUri); } }
public static String getPathForPreV19(Context context, Uri contentUri) { String res = null;
String[] proj = { MediaStore.Images.Media.DATA }; Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null); if(cursor.moveToFirst()){; int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); res = cursor.getString(column_index); } cursor.close();
return res; }
@TargetApi(Build.VERSION_CODES.KITKAT) public static String getPathForV19AndUp(Context context, Uri contentUri) { String wholeID = DocumentsContract.getDocumentId(contentUri);
// Split at colon, use second item in the array String id = wholeID.split(":")[1]; String[] column = { MediaStore.Images.Media.DATA };
// where id is equal to String sel = MediaStore.Images.Media._ID + "=?"; Cursor cursor = context.getContentResolver(). query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, column, sel, new String[]{ id }, null);
String filePath = ""; int columnIndex = cursor.getColumnIndex(column[0]); if (cursor.moveToFirst()) { filePath = cursor.getString(columnIndex); }
cursor.close(); return filePath; }
I have encountered this same issue. The pickers provided by the api in V19 and above may give you this result. Give the code below a try, should solve your issue.

----------

**Your modified code**
String path = FileUtility.getRealPathFromURI(context, Uri.parse(bitmapUri.getPath()); ExifInterface exif = new ExifInterface(path); rotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

----------

**FileUtility.java**
/** * Gets the real path from file * @param context * @param contentUri * @return path */ public static String getRealPathFromURI(Context context, Uri contentUri) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return getPathForV19AndUp(context, contentUri); } else { return getPathForPreV19(context, contentUri); } }
/** * Handles pre V19 uri's * @param context * @param contentUri * @return */ public static String getPathForPreV19(Context context, Uri contentUri) { String res = null;
String[] proj = { MediaStore.Images.Media.DATA }; Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null); if(cursor.moveToFirst()){; int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); res = cursor.getString(column_index); } cursor.close();
return res; }
/** * Handles V19 and up uri's * @param context * @param contentUri * @return path */ @TargetApi(Build.VERSION_CODES.KITKAT) public static String getPathForV19AndUp(Context context, Uri contentUri) { String wholeID = DocumentsContract.getDocumentId(contentUri);
// Split at colon, use second item in the array String id = wholeID.split(":")[1]; String[] column = { MediaStore.Images.Media.DATA };
// where id is equal to String sel = MediaStore.Images.Media._ID + "=?"; Cursor cursor = context.getContentResolver(). query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, column, sel, new String[]{ id }, null);
String filePath = ""; int columnIndex = cursor.getColumnIndex(column[0]); if (cursor.moveToFirst()) { filePath = cursor.getString(columnIndex); }
cursor.close(); return filePath; }

        
Present in both answers; Present only in the new answer; Present only in the old answer;