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

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

Gallery with folder filter

You just need to implement MediaScannerConnectionClient in your activity and after that you have to give the exact path of one of the file inside that folder name here as SCAN_PATH and it will scan all the files containing in that folder and open it inside built in gallery. So just give the name of … Read more

Get filepath and filename of selected gallery image in Android

Add this class in your project ImageFilePath.java import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.ContentUris; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.os.Environment; import android.provider.DocumentsContract; import android.provider.MediaStore; //import android.provider.<span id=”IL_AD11″ class=”IL_AD”>MediaStore</span>; @SuppressLint(“NewApi”) @TargetApi(Build.VERSION_CODES.KITKAT) public class ImageFilePath { /** * Method for return file path of Gallery image * * @param context * @param uri * … 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

How to pick an image from gallery (SD Card) for my app?

Updated answer, nearly 5 years later: The code in the original answer no longer works reliably, as images from various sources sometimes return with a different content URI, i.e. content:// rather than file://. A better solution is to simply use context.getContentResolver().openInputStream(intent.getData()), as that will return an InputStream that you can handle as you choose. For … Read more