我想在 Android 中创建一个新的“相册”。我不明白你必须用你自己的 ContentProvider 来做。但我无法弄清楚如何。如果您拍照,所有图像都会出现在“相机”相册中。如果您安装了 Google+,您会看到 2 个额外的相册:即时上传和个人资料照片。
我们想创造类似的东西。我们在网上为每个用户创建了一个相册,我们希望它在相册应用中显示为一个相册项。有人能指出我正确的方向吗。
我已经检查过:http://developer.android.com/guide/topics/providers/content-providers.html
实际上我不确定这是否可能。
最佳答案
您可以使用这种方式在图库应用中创建相册。该名称显示为“应用图片”。
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);
}
}
});
关于android - 在 Android Gallery App 中创建自定义相册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6683259/