gpt4 book ai didi

android - 如何在 android(2.1 或更高版本)上获取设备(特别是 sdcard)上的所有图像

转载 作者:太空狗 更新时间:2023-10-29 14:31:44 24 4
gpt4 key购买 nike

我已经按照这里的教程进行操作:http://androidsamples.blogspot.com/2009/06/how-to-display-thumbnails-of-images.html还有另一个代码几乎相同的代码,我在不同设备上处理图像的方式上遇到了一些问题/不一致。

我收集图像的代码是这样的:

private void init_phone_image_grid() {
String[] img = { MediaStore.Images.Thumbnails._ID };
Uri uri = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI;
imagecursor = managedQuery(uri, img, null,
null, MediaStore.Images.Thumbnails.IMAGE_ID);
image_column_index = imagecursor
.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);
count = imagecursor.getCount();
imagegrid = (GridView) findViewById(R.id.PhoneImageGrid);
imagegrid.setAdapter(new ImageAdapter(getApplicationContext()));
imagegrid.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView parent, View v, int position,
long id) {
System.gc();
String[] proj = { MediaStore.Images.Media.DATA };
actualimagecursor = managedQuery(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,
null, null, null);
actual_image_column_index = actualimagecursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
actualimagecursor.moveToPosition(position);
String i = actualimagecursor
.getString(actual_image_column_index);
System.gc();
Intent intent = new Intent(getApplicationContext(),
EvidenceImageView.class);
intent.putExtra("filename", i);
startActivity(intent);
}
});
}

我有一个运行 android 2.2 的模拟器,并且能够创建一个 sdcard 文件来挂载它。我使用 adb 将一些图像复制到一个文件夹中,然后重新启动了模拟器(我的应用程序一开始没有显示任何图像)。 . 重新启动后一些图像出现在我的应用程序中但不是全部.. 然后在我打开模拟器附带的 Gallery 应用程序后我能够让我的画廊加载所有图像就好了.. 但是我也有一台 HTC thunberbolt,上面有照片(在/sdcard/DCIM/100MEDIA 下)并且它不会在同一个应用程序中显示任何图像(指的是我正在处理的那个)。我没有将手机连接到计算机所以我知道我的手机没有问题能够访问 sdcard.. 我也试过手机附带的图库应用程序,我的照片/视频加载得很好.. HTC 手机附带的应用程序与普通 android 手机附带的应用程序有点不同我相信..这让我想知道系统是否没有以相同的方式处理图像..

我是 android 开发的新手,希望这会很简单。我查看了其他一些应用程序,例如 facebook,当我想上传照片..也许我可以采用同样的方法(不完全确定如何)..最终我希望用户能够选择多张图片并上传所有图片......我还找到了android自带的Camera app的源码:

https://android.googlesource.com/platform/packages/apps/Camera/+/master/src/com/android/camera

这有点用处,但此时有相当多的信息需要消化。

任何关于“这些东西是如何工作的”的解释都会很棒。但最主要的是,如何让我的图库显示所有缩略图(必要时创建缩略图)。或者,我如何与系统图库交互。

最佳答案

it appears to take me directly into the gallery provided by htc when I want to upload a photo.. Perhaps I could take this same approach

这有什么问题:

How to pick an image from gallery (SD Card) for my app?

关于android - 如何在 android(2.1 或更高版本)上获取设备(特别是 sdcard)上的所有图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5998595/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com