Hello i am using this code ( https://stackoverflow.com/a/6772455/579646 ) to open an image in Gallery, but on android 2.2 and 2.3 it shows a me Toast saying "searching for new images and albums ..." and then after about 10 seconds of blank screen it finally shows my image. Plus if i change the image but leave the same file name, the gallery cache kicks in(or something like that) and i see the old image when zoomed out and new picture when zoomed it. The only fix is to use random name every time.
If i use this link https://stackoverflow.com/a/5814533/579646 then it opens faster but then i invade the gallery and it adds a folder to it. Is there a way to remove the folder after the user closes the gallery ?
How can i make Gallery open just one Image without scanning stuff and without adding some folder to the gallery by mediascanner ?
Thanks
Your best option is to create your own Activity for displaying an image within your app (answers to this question should help). You then have complete control over the actions it does. Create a simple activity that takes a path to the image and simply opens that path and displays the image in a full-screen ImageView.
I say this because there's not much you can do about Gallery updating its cache whenever it opens - once you move to a different activity, your app has no influence. And ACTION_VIEW is the correct Intent to be opening an image, but remember that users may not have the standard gallery as the default activityfor it. If they have a different default, the experience might not be so bad.
Related
Okay so this might be a very silly question to ask.
Does a bitmap of an image remains constant traversing through different activities in the android.
Well my issue is :
I have an activity with image view having a default image.
I am previewing another image picked from the gallery if the user wants it.
So now then i move on to the next activity displaying the image user picked from the gallery.
Now if the user hasn't picked any image i want to show another default image.
Please note not the 1st default image in 2nd activity.
If a bitmap remains in the drawables folder, then you can access it from every Activity and it will remain "constant" so to say (if that's what you meant). If you're using the bitmap in the code (to set it as the background of the ImageView), then this can be changed - othwerise if in drawables - it's just usable, you can manipulate it, but you will never change its basic status (in the folder).
I've just written an app with a nice photo gallery for iOS, now I'd like to do the same thing with my Android version of the app. I see that the Android Gallery API allows me to build a scrolling gallery of images. But what I really want is an apple-photo gallery style interface with a grid of thumbnails which, when tapped, open up a full screen display of the selected image and allows me to navigate through the photo gallery using swipes or left/right arrows on a tool bar.
In iOS I used the KTPhotoBrowser to achieve this interface, but I haven't been able to find anything like that for Android. Can anybody point me to a library, or even a tutorial with example code which will give me an interface like that without having to roll it myself?
Update: I've found the GridView Tutorial which describes how to put image thumbnails into a grid, seems to be the perfect thing. The Gallery API can be used for the full size photo browser as shown in #ariefbayu sample code (see link in comments below). It's not quite the same as the iPhone style gallery, but it's pretty good.
I've done this kind of interface. The basic is:
MainActivity load images into GridView.
On each Gallery click, load another activity using Intent, called SlideActivity which extends 'Gallery' in full screen mode where this will:
show Gallery and set current image to selected
set currently selected image in gallery, to what is clicked in first layout.
Link to sample code: https://www.dropbox.com/s/xk2oupma8zcxqpf/GridToGallery.zip
I have my app working where it comes to a screen with 6 thumbnails. The user will select one and the next screen is a full image. I've accomplished this through an OnClickListener to call a new activity/xml (I'm new at this, sorry if my terminology is a little off).
My question is: is there a way to avoid creating 6 activty/xml (one for each thumbnail)? ultimately, my app will have about 40 thumbnails that can be selected for full screen view.
I've been trying to follow examples online where it appears that the code is presenting the full image within java instead of referencing an xml file. I've also seen use of Bitmap and BitmapFactory. Is this the way to go?
If the full screen image can be created dynamically within java, will the Back button still work to the user back to the screen with 6 thumbnails?
thanks, J
The simplest approach to take is to pass a reference to the image in the intent you use to launch the full-screen activity.
You can use the BitmapFactory to create a Bitmap, and then update the ImageView (or however you're displaying the image) from the loaded bitmap.
Using this approach, the back button will still work normally, but you'll only need one activity to display the full-screen image.
I have an app that have more than one gallery. It is a travel app and it have a separate gallery for each trip. When I'm taking pictures with the camera I'm saving them in the default MediaStore of the system.
To view an Image I'm using new Intent(Intent.ACTION_VIEW) and it launches the default image viewer. When scrolling with the left and right arrows it displays all the pictures in the folder where the pictures from the camera are saved.
Is there any way to put an extra in the intent when calling VIEW action which images to scroll trough? I have the IDs of the images for a certain trip in a database.
Or putting them in a separate folder is the only solution?
You could also consider building your own preview activity using a GridView. Of course this is more work to do, but also offers more flexibility:
You can create "virtual" folders
You can display images from local store or from the net (if you want to offer synchronization with web albums for example)
You can highlight certain images (favorite, shared)
I am new to android, I have learned how to display drawable pic in gallery,
and display a url pic use ImageView. Now I dont know how to display online pictures in gallery. Should I use listview or not? In addtion, I want to know how to get pictures urls from flickrs with given userid
Do you mean like a photo gallery? is that what your app is supposed to do? Then, yes you could use a ListActivity/ListView. However i do not know if this will provide you with exactly the effect you want. A list view would load ALL of the pictures before the UI could be displayed and you would view them by scrolling. typically a photo viewer shows pictures full screen and switches with either a button or a swipe (gesture).
To get the latter effect, your app could display an ImageView with the first pic while it loads the next pic, and then switch to a new ImageView when the user clicks a button or swipes. this will prevent your app from eating up resources and will give you an interface that people are more used to.
as for flickr, you will have to ask someone else (you should separate these into two separate questions because they are so different)