从网络上保存图像时出现问题。Android需要帮助来对网络上的图像进行排序
我创建了新文件夹并将所有图像保存到此目录。问题是我希望这个文件夹顺序是由上一个下载图像开始的,但是当我打开图库时,该文件夹是由创建的图像日期排序的,并且在下载的图像中创建的日期不是我下载的时间,但是第一次创建。我已经在stack over flow上进行了搜索,发现java无法修改映像中创建的日期,直到我下载它为止。
任何人都有解决方案? (对不起英文对不起)
感谢您的评论。我将解释更多细节。
首先,我从网站上下载图像缓存目录
HttpURLConnection localHttpURLConnection = (HttpURLConnection) new java.net.URL(urldisplay).openConnection();
localHttpURLConnection.setConnectTimeout(30000);
localHttpURLConnection.setReadTimeout(30000);
localHttpURLConnection.setInstanceFollowRedirects(true);
InputStream in = localHttpURLConnection.getInputStream();
File localFile = Constans.fileCache.getCacheFile(urldisplay);
FileOutputStream fos = new FileOutputStream(localFile);
Utils.CopyStream(in, fos); // simple copy by trunks
fos.close();
其次,我复制图像下载到外部存储器
File toFile = new File(Environment.getExternalStorageDirectory() + "/folder", "folder_" + System.currentTimeMillis() + ".png");
FileOutputStream fos = new FileOutputStream(toFile);
Utils.CopyStream(new FileInputStream(fromFile), fos);
fos.close();
// Scan image to display when open with gallery otherwise it couldn't see in gallery
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri contentUri = Uri.fromFile(toFie);
mediaScanIntent.setData(contentUri);
mContext.sendBroadcast(mediaScanIntent);
最后,我看到画廊不要排序我的形象我下载的时间。这是我想解决的问题。
请添加一些代码,和细节。 你使用android的galary或galary视图吗? –
谢谢iu回答我。我已经解释了更多细节。你能提供更多帮助吗? – MashiMaro