开发者

How to implement custom device photos gallery for android?

I'm working on android application that will have basic image gallery functionality included. I've managed to build activity that fetches list of photos from my application backend API and render them in android gridview within activity layout.

This is how it looks like at the moment:

How to implement custom device photos gallery for android?

However I'm having difficulties to build same gallery experience for user's device photos that were taken by camera and stored on device. Two solutions I considered were:

  1. Building my own image gallery.
  2. Starting default android image gallery using intent.

Solution 1: I belive that first solution will take me too much ti开发者_JAVA技巧me to developed. I started with this tutorial but as soon I implemented it I found out that it is running too slow. Then I take a look at android camera source code to find solution but again I found that it will take me too much time to review the code and to build my own gallery from scratch. I also believe that it is not in Android OS philosophy to rewrite functionalities that already exists but to use Intents to start activities that can handle actions you need. This lead me to second solution.

Solution 2: I tried calling default android gallery using intent in order to browse user's device photos by soon I was stuck again. Problem this time was that as soon as user tap on photo, gallery exits and returns to activity that originaly started it, and I expected (and I want) to start large image preview instead. I saw that others had this problem too how to open gallery via intent without result. Because I didn't find the fix for this I decided to quit.

My question is how can I overcome these problems and build gallery that is similar to one I already have for web photos. If anyone could give me reference I would be most thankful.


this question is pretty old but, as it has a lot of views and quite a lot of upvotes, it could be good to bring an answer to it.

So, first the tutorials evolved a bit and you can find some cool stuff for your #1 option:

  • This is the one I prefer
  • This one uses a deprecated UI element but is also cool
  • This uses an Adapter which is, to me, the best way to proceed.

For your #2 option, I do not see any idea to not to return to the original activity because you still do not have control over the result of the intent you send through the system.

But there are another solution that you didn't mention: there are librairies which are very cool and that you could customise to get exactly what you want:

  • This one is a bit fancy
  • This one seems also to be pretty cool but you could have problems importing it because it's not a gradle project
  • This is the one I would definitely use.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜