我正在youtube上学习一个视频教程来制作相机应用程序
https://www.youtube.com/watch?v=GH9CPeurBco
在6:42,他写了data.getExtras();。当我试图键入时,我在.getExtras();上得到了无法解决method' getExtra()'的错误“。我键入的和他完全一样。我现在该怎么办?
这里是代码:
protected void onActivityResult(int requestcode, int resultcode, int data) {
if (requestcode == Activity_Start_Camera_App && requestcode == RESULT_OK) {
//Toast.makeText(this, "picture taken successfull", Toast.LENGTH_SHORT).show()
Bundle extras = data.getExtras();
Bitmap photoCapturedBitmap = (Bitmap) extras.get("data");
mPhotoCapturedImageView.setImageBitmap(photoCapturedBitmap);
}发布于 2016-12-24 11:58:17
您重写了一个错误的方法。第三个参数是Intent而不是int
实际的方法是:
@Override
protected void onActivityResult(int requestcode, int resultcode, Intent data) {
if (requestcode == Activity_Start_Camera_App && requestcode == RESULT_OK) {
//Toast.makeText(this, "picture taken successfull", Toast.LENGTH_SHORT).show()
Bundle extras = data.getExtras();
Bitmap photoCapturedBitmap = (Bitmap) extras.get("data");
mPhotoCapturedImageView.setImageBitmap(photoCapturedBitmap);
}发布于 2016-12-24 12:27:27
您重写了错误的方法。
它应该是:
protected void onActivityResult(int requestcode, int resultcode, Intent data) {
if (requestcode == Activity_Start_Camera_App && requestcode == RESULT_OK) {
//Toast.makeText(this, "picture taken successfull", Toast.LENGTH_SHORT).show()
Bundle extras = data.getExtras();
Bitmap photoCapturedBitmap = (Bitmap) extras.get("data");
mPhotoCapturedImageView.setImageBitmap(photoCapturedBitmap);
}https://stackoverflow.com/questions/41313012
复制相似问题