我是Android开发的新手。
请帮我解决以下问题。当我尝试使用函数更新小部件时,我在Logcat上收到错误“system.out - resolveuri failed on bad bitmap uri”,
remoteViews.setImageViewUri(R.id.clockview, buildUpdate("CURRENTTIME", c));
awm.updateAppWidget(awID, remoteViews);
我附上我的代码: -
public Uri buildUpdate(String time, Context context) {
date = new Date();
sec = (float) date.getSeconds();
min = (float) date.getMinutes();
hour = (float) date.getHours() + min / 60.0f;
bitmap = Bitmap.createBitmap(200, 200, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint p = new Paint();
p.setAntiAlias(true);
p.setColor(0xFFFF0000);
p.setStrokeWidth(2);
canvas.drawLine(
x,
y,
(float) (x + (r - 15)
* Math.cos(Math
.toRadians((hour / 12.0f * 360.0f) - 90f))),
(float) (y + (r - 10)
* Math.sin(Math
.toRadians((hour / 12.0f * 360.0f) - 90f))), p);
...
...
OutputStream outStream = null;
File file = new File("data/clockbitmap.PNG");
try {
outStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
}
catch(Exception e)
{}
uri = Uri.parse(file.getAbsolutePath());
Log.d("File","filename "+file);
Log.d("here", "Does this exist? " + String.valueOf
(file.exists()));
Log.d("here",uri.getPath());
return uri;
}
请帮我解决这个问题。!!!!! :(
答案 0 :(得分:0)
当你从SD卡读取文件时,路径可以被命名为“file:///(绝对路径。)”
我觉得这会解决URI解析问题。