日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > Android >内容正文

Android

android 浏览指定相册,Android -- 采用系统相册浏览指定路径下照片

發(fā)布時(shí)間:2025/3/15 Android 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 浏览指定相册,Android -- 采用系统相册浏览指定路径下照片 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

//打開系統(tǒng)相冊(cè)

Intent intent=new Intent(Intent.ACTION_GET_CONTENT);

intent.setType("image/*");

startActivity(intent);

//打開指定的一張照片

Intent intent = new Intent();

intent.setAction(android.content.Intent.ACTION_VIEW);

intent.setDataAndType(Uri.fromFile(pictureFilepath), "image/*");

startActivity(intent);

//打開系統(tǒng)相冊(cè)瀏覽照片

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/internal/images/media"));

startActivity(intent);

// 采用MediaScannerConnection掃描制定路徑下的圖片文件,并啟動(dòng)系統(tǒng)相冊(cè)進(jìn)行瀏覽

自己寫的一個(gè)類

public class PictureScanner implements MediaScannerConnection.MediaScannerConnectionClient{

private MediaScannerConnection mMs;

private File mFile;

private Context context;

File[] allFiles ;

public PictureScanner(Context context) {

File folder = new File(pictureFolderPath);

allFiles = folder.listFiles();

swap(allFiles);

this.context = context;

mFile = allFiles[0];

mMs = new MediaScannerConnection(context, this);

mMs.connect();

}

public void onMediaScannerConnected() {

mMs.scanFile(mFile.getAbsolutePath(), null);

}

public void onScanCompleted(String path, Uri uri) {

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setData(uri);

context.startActivity(intent);

mMs.disconnect();

}

private void swap(File a[]){

int len = a.length;

for(int i=0;i

File tmp = a[i];

a[i] = a[len-1-i];

a[len-1-i] = tmp;

}

}

}

//調(diào)用

new PictureScanner(MyActivity.this);

原文:http://blog.csdn.net/tanmengwen/article/details/42061471

總結(jié)

以上是生活随笔為你收集整理的android 浏览指定相册,Android -- 采用系统相册浏览指定路径下照片的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。