我可以使用URI方法ImageManager中的getUnlockedImageUri显示成就图片但由于某些原因,我需要找到图片的本地路径,因为我不想使用ImageView,我需要图像的实际文件路径
Google Play游戏成就的URI看起来像这样content://com.google.android.gms.games.background/images/d2bbfba4/61
,我希望能够将其转换为File
对象,如下所示:
File myFile = new File(ach.getUnlockedImageUri().getPath());
Log.i(ExConsts.TAG, "myFile.exists() = " + myFile.exists());
// returns false!
但这不起作用!任何想法为什么?或者我应该尝试什么?或者甚至告诉我它是否可能?
答案 0 :(得分:0)
content://
Uri是一个明确的标志,
如getRevealedImageUri() Javadoc中所述:
要从Uri检索图像,请使用ImageManager。
您可以使用ImageLoader.loadImage(OnImageLoadedListener, Uri)获取Drawable
,Canvas
可以使用Drawable.draw(Canvas)在Drawable
上绘制。
如果您愿意,可以使用与this answer类似的内容将Bitmap
转换为var itemText = document.getElementById("item_", + boxId);
。