how to add images to android emulator?

Goto the DDMS tool in eclipse to push or pull a file onto the emulator. Then go into the running emulator itself, select “Dev Tools” from the Apps screen, select “Media Scanner” (or “Media Provider” in newer versions of Android) to get the emulator to recognize the files so they would be displayed in the … Read more

Get filepath and filename of selected gallery image in Android

A little late to the party but here’s my code, hope this helps. public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { Uri selectedImageUri = data.getData( ); String picturePath = getPath( getActivity( ).getApplicationContext( ), selectedImageUri ); Log.d(“Picture Path”, picturePath); } } public static String getPath( Context context, Uri uri ) … 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

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