Choosing photo using new Google Photos app is broken

Below code is working for me to get content URI on latest Google Photos as well. What i have tried is writing to temp file and return temp image URI, if it has authority in content URI. You can try same: private static String getImageUrlWithAuthority(Context context, Uri uri) { InputStream is = null; if (uri.getAuthority() … Read more

Get Image from the Gallery and Show in ImageView

you can try this. paste this code in your button click event. Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType(“image/*”); startActivityForResult(photoPickerIntent, RESULT_LOAD_IMG); and below code is your on activity result @Override protected void onActivityResult(int reqCode, int resultCode, Intent data) { super.onActivityResult(reqCode, resultCode, data); if (resultCode == RESULT_OK) { try { final Uri imageUri = data.getData(); final InputStream … Read more

Android getting an image from gallery comes rotated

You could use ExifInterface to modify the orientation: public static Bitmap modifyOrientation(Bitmap bitmap, String image_absolute_path) throws IOException { ExifInterface ei = new ExifInterface(image_absolute_path); int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: return rotate(bitmap, 90); case ExifInterface.ORIENTATION_ROTATE_180: return rotate(bitmap, 180); case ExifInterface.ORIENTATION_ROTATE_270: return rotate(bitmap, 270); case ExifInterface.ORIENTATION_FLIP_HORIZONTAL: return flip(bitmap, true, false); case ExifInterface.ORIENTATION_FLIP_VERTICAL: return … Read more

How to implement HorizontalScrollView like Gallery?

Try this code: activity_main.xml <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”fill_parent” android:layout_height=”100dip” tools:context=”.MainActivity” > <HorizontalScrollView android:id=”@+id/hsv” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:layout_alignParentTop=”true” android:fillViewport=”true” android:measureAllChildren=”false” android:scrollbars=”none” > <LinearLayout android:id=”@+id/innerLay” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:gravity=”center_vertical” android:orientation=”horizontal” > <LinearLayout android:id=”@+id/asthma_action_plan” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:gravity=”center” android:orientation=”vertical” > <RelativeLayout android:layout_width=”fill_parent” android:layout_height=”match_parent” > <ImageView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:src=”https://stackoverflow.com/questions/18656949/@drawable/action_plan” /> <TextView android:layout_width=”0.2dp” android:layout_height=”fill_parent” android:layout_alignParentRight=”true” android:background=”@drawable/ln” /> </RelativeLayout> </LinearLayout> <LinearLayout android:id=”@+id/controlled_medication” android:layout_width=”wrap_content” android:layout_height=”wrap_content” … Read more

Allow user to select camera or gallery for image

How to launch a single Intent to select images from either the Gallery or the Camera, or any application registered to browse the filesystem. Rather than creating a Dialog with a list of Intent options, it is much better to use Intent.createChooser in order to get access to the graphical icons and short names of … Read more

Android Gallery on Android 4.4 (KitKat) returns different URI for Intent.ACTION_GET_CONTENT

This requires no special permissions, and works with the Storage Access Framework, as well as the unofficial ContentProvider pattern (file path in _data field). /** * Get a file path from a Uri. This will get the the path for Storage Access * Framework Documents, as well as the _data field for the MediaStore and … Read more