Daniel Gomes Daniel Gomes - 1 month ago 11
Android Question

Android - Back button closing app when I use intent.setAction(Intent.ACTION_VIEW);

I want to see a image in gallery and it's working fine, the problem is that if I click on the top back button, I return to gallery and not to the app. If I click on the back button in the bottom, I go back to the app as it should.
Click here to see the back button that doesnt work

That's the snippet for starting the intent:

final Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + path), "image/*");
activity.startActivityForResult(intent, ChatActivity.GALLERY_INTENT_CALLED);

Answer

What you refer as the "top back button" does not go back. It goes where the developer of the app wants it to go. You did not write this gallery app, and so you do not control where it goes.

Google calls this "up navigation", and ostensibly it is supposed to go up a navigational hierarchy within the app that you are in.

In short: this is perfectly normal, it has nothing to do with your code, and there is nothing that you can do about it.