I call android system camera:
Uri uri = Uri.fromFile (new File (imagepath));
Intent intent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra (MediaStore.EXTRA_OUTPUT, uri);
mactivity.startActivityForResult (intent, 2);
Open system camera, and rewrite the onActivityResult (int requestCode, int resultCode, Intent data) methods.
@ Override
public void onActivityResult (int requestCode, int resultCode, Intent data) {
super.onActivityResult (requestCode, resultCode, data);
if (requestCode == 2 && resultCode == RESULT_OK)
{
cameraview.iview.setImageURI (Uri.fromFile (new File (cameraview.imagepath)));
Bitmap bmp = (Bitmap) data.getExtras () get ("data");.
Log.d ("Test", "bmp width" + bmp.getWidth () + ", height:" + bmp.getHeight ());
}
}
I take pictures, click on the OK button, nothing happens. Click Cancel button before the onActivityResult callback method.
Please enlighten the great God, why click "OK" onActivityResult no callback method? ? ? ?
Reply:
Wording right, you put && resultCode == RESULT_OK get rid of this judgment.
You on the other phone is so?
Reply:
http://blog.csdn.net/shen332401890/article/details/9313379
Reference
In addition, your launchmode application is valid? By default it?
Also try upstairs first try without judgment conditions
Reply:
I replied under the 1st and 2nd floor problems.
About resultCode == RESULT_OK this judgment until after I was done together with comparative tests.
No resultCode == RESULT_OK before this condition, the result is the same.
The key is to ask when you do not have to enter onActivityResult select OK () This method will not even go resultCode == RESULT_OK this judgment.
Also launchmode should be the default, because I did not move a thing about launchmode.
Thank you.
Reply:
I'll give you first download what you connect the provided code to see results. That is what I debugged program! ! ~
There loom Try changing your code
Reply:
Well I try it.
Reply:
Handsome returns after the electricity supplier references or else you do not see ah! ! ~! ~! ~
Reply:
Please make sure you provide the next guy this thing really. http://blog.csdn.net/shen332401890/article/details/9313379
I downloaded this project there is no code. Empty. Really.

Reply:
I am sorry that I made a mistake. I try again.

Reply:
CSDN and maybe a problem, download upload resources out there is a problem previously encountered, such as time and then download it! ~

Reply:
I have read that code. And I was not much different.
Intent takePictureIntent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.putExtra (MediaStore.EXTRA_OUTPUT, Uri.fromFile (f));
I just set putExtra () when the MediaStore.EXTRA_OUTPUT replaced MediaStore.EXTRA_SHOW_ACTION_ICONS, after clicking OK and callback parameters can also correct.
But this is no way to save the image path.
I used to say MediaStore.EXTRA_OUTPUT or not, in the true way will still choose to save the old problem.
Reply:
I suspect that you tune camera application has a problem, you try to re-install the application to try one of the other camera
Reply:
I found a problem.
In onActivityResult (int requestCode, int resultCode, Intent data) this method.
If you click OK data value should be NULL click Cancel, data have value.
I putExtra () parameter to MediaStore.EXTRA_SHOW_ACTION_ICONS the first time. Determine whether or canceled, although you can callback onActivityResult () method, but there is a value of data has been worth it.
And when I changed right MediaStore.EXTRA_OUTPUT. Click OK to not be able to call back to onActivityResult () method.
So I suspect that limit before the internal callback onActivityResult () method, for which the parameter data has been set, it is possible when data is NULL, do not return to onActivityResult () This method has. This is just my guess.
CAMERA also you have to say there are problems mean? I call the system CAMERA, CAMERA you say that the system in question is not it?
Or CAMERA version of this method or a problem?
Halo ah, this problem has troubled me for two days.
Reply:
I am referring to here is the system Camera Camera application, you can try to install other applications are OK
Camera
Reply:
OK.
Problem solved.
The last issue is discovered, save the file in the wrong path.
I define a path String imagepath = "/ storage/sdcard0/text/touxiang.png";
Although the prior written
when creating the fileif (! vFile.exists ()) {
File vDirPath = vFile.getParentFile ();
vDirPath.mkdirs ();
}
Ensure that the path is absolute existence, but in the new File (imagepath); then finds the path.
So then create or useless. Then I create the correct path.
Press the OK button on the call to onActivityResult (). And successfully saved.
Reply:
Pro, if you MediaStore.EXTRA_OUTPUT time, data is null, this is true, and you just like to delete this parameter, namely intent.putExtra (MediaStore.EXTRA_OUTPUT, path); without the phrase, if it sentence, you do not judge data in onactivityresult, the picture content taken directly from the path path ~ ~
Reply:
Your pictures are thumbnails so save it
No comments:
Post a Comment