I am developing an application in Android Studio and testing it with my smartphone 4.2.2, I need to take a photo first and get its Uri to then cut it out. On the internet I found that for that it is used:
url = data.getData();
But in the same way I investigated that in Jelly bean this does not work like that, and indeed because what I get as a result is NULL even though the photo does capture it. I've been trying everything for hours but until now I can not find something to solve the problem. Is there another way to get the Uri? Thanks
Annex the rest of the code just in case.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_eslyss);
boton = (Button) findViewById(R.id.button);
boton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dispatchTakePictureIntent();
}
});
}
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap bitmap2 = (Bitmap) extras.get("data");
uri = data.getData();
Intent intent = new Intent();
intent.setClass(Activity.this, Salto1.class);
intent.putExtra("Bitmap", bitmap2);
startActivity(intent);
}
}