Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a custom album in the Android Gallery App

I want create a new 'album' in Android. I unserstood that you have to do it with your own ContentProvider. But i can't figure out how. If you take pictures, all the images appear in the album 'Camera'. If you have installed Google+ you'll see 2 extra albums: Instant Upload & Profile Picture.

We want to create something similar. We have an album per user online and we want that it appears as an album item in the Gallery app. Can someone point me in the right direction.

I already checked: http://developer.android.com/guide/topics/providers/content-providers.html

Actually im not really sure if it is possible.

like image 951
lukin Avatar asked Jul 13 '11 17:07

lukin


People also ask

How do I create a favorite Album on Android?

CREATE A FAVORITES PHOTO ALBUMOpen Photos, then tap the Heart icon at the bottom of screen for each of your favorite photos. All selected photos will move to Favorites album.


1 Answers

You can use this way to create album in Gallery app. The name appears as 'app images'.

String path = Environment.getExternalStorageDirectory().toString();
File dir = new File(path, "/appname/media/app images/");
if (!dir.isDirectory()) {
        dir.mkdirs();
}

File file = new File(dir, filename + ".jpg");
String imagePath =  file.getAbsolutePath();
    //scan the image so show up in album
MediaScannerConnection.scanFile(this,
        new String[] { imagePath }, null,
        new MediaScannerConnection.OnScanCompletedListener() {
        public void onScanCompleted(String path, Uri uri) {
        if(Config.LOG_DEBUG_ENABLED) {
            Log.d(Config.LOGTAG, "scanned : " + path);
        }
        }
});
like image 84
angelokh Avatar answered Oct 12 '22 09:10

angelokh