gallery

Single intent to let user take picture OR pick image from gallery in Android

狂风中的少年 提交于 2019-11-28 02:44:47
I'm developing an app for Android 2.1 upwards. I want to enable my users to select a profile picture within my app (I'm not using the contacts framework). The ideal solution would be to fire an intent that enables the user to select an image from the gallery, but if an appropriate image is not available then use the camera to take a picture (or vice-versa i.e. allow user to take picture but if they know they already have a suitable image already, let them drop into the gallery and pick said image). Currently I can do one or the other but not both. If I go directly into camera mode using

how to save bitmap to android gallery

时光怂恿深爱的人放手 提交于 2019-11-28 01:30:51
unfortunately the solutions I've found didn't work on android 5.1.1. I have a bitmap called source. I need to save it directly to my phone's gallery. My manifest contains <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> Can you give me a working method to do this? Use this one: private void saveImage(Bitmap finalBitmap, String image_name) { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root); myDir.mkdirs(); String fname = "Image-" + image_name+ ".jpg"; File file = new File(myDir, fname); if (file.exists()) file.delete();

BitmapFactory.decodeStream(InputStream is) returns null for non null InputStream on Android

别来无恙 提交于 2019-11-28 01:20:46
I'm developing an Android application, and it's view is containing multiple Gallerys. The content of the Gallerys (the Bitmaps) are red from the Internet. For the first gallery, everything works fine, but when trying to download the first image of the second Gallery, the BitmapFactory.decodeStream(InputStream) returns null, while the stream is NOT null. public void loadBitmap() throws IOException { for (int i = 0; i < images.size(); ++i) { URL ulrn = new URL(images.get(i).getThumbUrl()); HttpURLConnection con = (HttpURLConnection) ulrn.openConnection(); InputStream is = con.getInputStream();

Save cache when rotate device

会有一股神秘感。 提交于 2019-11-28 00:37:14
I have a Gallerywiew . I'm using lazyload to download images but when I rotate device it reloads all images and does not use the cache. If I do android:configChanges="keyboardHidden|orientation" the current images are in size of latest orientation. To get the images to show full size I do: Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); Overriding onConfigurationChanged() is discouraged because there's so much work you have to do to get it right. What you want to do is implement

Automatic horizontal scroll in TextView

牧云@^-^@ 提交于 2019-11-27 22:23:25
问题 I have custom gallery. Gallery represents items that are frame layout. There are one imageView and textView above it. If text in textView is too long, i need it to be scrolled automatically. It's one line of text, and it's needed to be scrolled horizontally. I've found this snippet of code: TextView android:text="Single-line text view that scrolls automatically" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit ="marquee_forever" android:focusable="true" android

How to add an image to the emulator gallery in android studio?

淺唱寂寞╮ 提交于 2019-11-27 19:35:56
I am developing an image filter app. But can't really try it if i don't have any images. I know that i can test it in the phone, but it's not the same, since I need the error messages and other stuff. I just want to access an image from the AVD's gallery so that I can test my app. How can I add one? I am using Android Studio. I saw some examples on how to do it in Eclipse, but i am not using that. So, how can I add an image to the emulator image gallery? Its very old question but I will answer this for future references. To add any file to emulator Just drag and drop the file the file will be

Android Gallery with pinch zoom

荒凉一梦 提交于 2019-11-27 18:51:05
I found a sample project of gallery with pinch zoom and made some bug fix. You can download my code at here It supports full screen only. It always center the image to screen height. But I want to put a header view to the top of the screen and make the adjustment to the location of the image. The image location should be: header height + (screen height - header height) / 2 I am not so good at using Matrix . Anyone has idea of how to make the customized gallery to work in any size (not just full screen)? You can use my Pinch to zoom Gallery project. You can choose any image from gallery and

Text Gallery on Android?

浪子不回头ぞ 提交于 2019-11-27 18:38:17
I have a gallery with the TextView to achieve the segment controller on the image below. I can achieve it by the ApiDemo's Gallery Example but I am lagging on the look and feel of the gallery. I want to do the backgrounds, Selected/deselected and selected item won't be cone to the center of the screen. Any Idea or Articles are most Thankful. image http://www.freeimagehosting.net/uploads/cce47da969.png I have tried to get using 2 ways. that are: Gallery View horizontal ScrollView The ouput getting is in the below image: image http://www.freeimagehosting.net/uploads/b4c1be5924.png I have Problem

Does a replacement for Gallery widget with View recycling exist?

爱⌒轻易说出口 提交于 2019-11-27 18:37:44
The default Gallery widget on Android does not recycle views - everytime the view for a new position is called the widget always calls the getView method of the adapter with convertView set to null. As you scroll backwards and forwards this ends up in lots of views being created, which the recycler component that the Gallery stores them in does not seem to recycle them quickly enough leading to an OOM situation. You can test this easily with a few large-ish images as your gallery items, but just a TextView will cause it in the end. Put a log statement with a counter in the getView method of

How to make intent chooser for camera or gallery application in android like whatsapp editprofile?

萝らか妹 提交于 2019-11-27 18:17:25
问题 I am developing an application where i need to have a dialog choose for uploading image from gallery or camera. I have found kind of solution here Dialog to pick image from gallery or from camera but the problem is here there is clash in comparing which action is chosen by user. I would like to know if i can modify in this code and get some result to differentiate either gallery or camera is chosen and then apply action. 回答1: Create new method into Main Activity File called “selectImage()”.