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:
alt text

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 time 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.

7
задан Community 23 May 2017 в 10:32
поделиться