Answer the question
In order to leave comments, you need to log in
Why doesn't the camera start via intent on Android 9.0?
I am making an android application. At the moment of pressing the button, I need to: open the camera so that the user takes a picture, and if everything went well, then send it to the server.
I write this code:
private void comeBtnClicked() {
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0 && resultCode == RESULT_OK) {
Bitmap image = (Bitmap) data.getExtras().get("data");
Toast.makeText(This, image.toString(), Toast.LENGTH_LONG).show();
}
}
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
Answer the question
In order to leave comments, you need to log in
Where is the permission check?
Starting from the 6th version, this is a mandatory requirement in Android.
It is necessary to check whether the rights to the camera are given and if not, then request the rights (show the window), get the result, process it and take the photo again.
If you look at the logs, you will see an error.
She will be about it.
Please send error logs next time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question