How to open one particular folder from gallery in android?

Use this following code to get a particular folder image. import java.io.File; import android.app.Activity; import android.content.Intent; import android.media.MediaScannerConnection; import android.media.MediaScannerConnection.MediaScannerConnectionClient; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class SDCARD123Activity extends Activity implements MediaScannerConnectionClient { public String[] allFiles; private String SCAN_PATH ; private static final String FILE_TYPE=”image/*”; private … Read more

How to access an image from the phone’s photo gallery?

You have to launch the Gallery App using the built-in Intents. After that, on your onActivityResult(), get the path of the selected image and load your image into your ImageView main.xml <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”@string/hello” /> <Button android:id=”@+id/loadimage” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”Load Image” /> <TextView android:id=”@+id/targeturi” android:layout_width=”fill_parent” … Read more

Loading all the images from gallery into the Application in android

Working solution with the help of Glide. Bonus part is Glide will auto play Gif . import java.util.ArrayList; import android.app.Activity; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.provider.MediaStore.MediaColumns; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; import android.widget.Toast; import com.bumptech.glide.Glide; /** * The Class GallarySample. */ public … 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

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

Android : How to detect the image orientation (portrait or landscape) picked from gallery while setting on an imageview?

Use ExifInterface for rotate image. Use this method for get correct value to be rotate captured image from camera. public int getCameraPhotoOrientation(Context context, Uri imageUri, String imagePath){ int rotate = 0; try { context.getContentResolver().notifyChange(imageUri, null); File imageFile = new File(imagePath); ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath()); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: … 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

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

Just wanted to say that this answer is brilliant and I’m using it for a long time without problems. But some time ago I’ve stumbled upon a problem that DownloadsProvider returns URIs in format content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fdoc.pdf and hence app is crashed with NumberFormatException as it’s impossible to parse its uri segments as long. But raw: segment … Read more