我想获取imageview realPath并编写textview。我可以在库中获取RealPath,但不能在相机中获取
这是我的代码
此代码采用库管理路径
private void takeLibrary(int sdk, String uriPath,String realPath){
this.txtSDK.setText("Build.VERSION.SDK_INT: "+sdk);
this.txtUriPath.setText("URI Path: "+uriPath);
this.txtRealPath.setText(realPath);
Uri uriFromPath = Uri.fromFile(new File(realPath));
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uriFromPath));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
imageView.setImageBitmap(bitmap);
}
还有这台相机
private void onCaptureImageResult(Intent data) {
// ????????????
}
?? 我应该写什么请帮助 谢谢
答案 0 :(得分:0)
在that之后,尝试以下操作:
UserController < ActiveRecord::Base
.....
def psychometric_assessment #Define routes to call this method
****YOUR LOGIC*****
end
.....
end
答案 1 :(得分:-1)
`write this piece of code in OnActivityResult()
1. `if (requestCode == CAMERA) {
if (data.getExtras().get("data") != null) {
bitmap = (Bitmap) data.getExtras().get("data");
uri = getImageUri(this, bitmap);
}
}
2. Add this function in the class.
public Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);// this will give you the path of the image
return Uri.parse(path);
}