I have a button which opens the android gallery app. I use the code
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"content://media/internal/images/media"));
startActivity(intent);
for Android>=2.3 found here: Open Gallery App in Android
My problem: When the user opens the gallery from my app and leaves gallery (home button, share image,..), then the gallery will show up next time the user opens my app (without button click).
How can I avoid the gallery is shown in my app when opening my app? The gallery should only be shown once when the button is clicked, but not next time my app gets in front.
Your best option given what your requirements appear to be is to tell Android not to save the Gallery in your task's history. That way, when they leave the Gallery activity it will not appear in the task's history stack. Do that by setting a flag on your intent.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/internal/images/media"));
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
Related
I have following piece of code,
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
intent.setType("image/*");
startActivityForResult(intent, IMAGE_PICK);
When i try to choose image, it opens recents in one flavour of app and in another, it opens screenshots, is there a way I can force to open same directory/folder inside gallery app so behaviour is synced on both flavours.
It seems to start in the last folder a photo was selected from. I.e. if I open app A and set an image from folder “Foo”, it will open in “Foo” the next time as well. The setting is separate for the app B. If I set an image from folder “Bar” in the app B it will open in “Bar” the next time in the app B, but still “Foo” for the app A.
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);
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.
I have opened image from Uri it work good for me at 4.3 version But in 4.4 version it show a back button on top of image and when i clicked on that back button it take me gallery so in this case i am going out of my app so how can prevent this please help me..below is my code.
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File photo_file = new File(path);
intent.setDataAndType(Uri.fromFile(photo_file), "image/*");
startActivity(intent);
That isn't a back button - it is an Up button, providing ancestral navigation within the Gallery/Photo viewing app. You'll note the back button still works as you expect, providing temporal navigation (i.e., back from where you came from).
There's no way to customize the view of another activity you do not own, although you can certainly go about and create a photo viewer of yourself where you get full control of the UI.
I have a webview activity and button to open a website in default browser after user clicks on
show more button.I destoy the webview activity after launching the browser intent as shown in the code below.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
finish()
My problem is,
i) After launching 2-3 websites using the intent it stops loading the website in the browser
ii) Sometimes it launches the browser on click of button but loads previous url which was opened in the browser.
iii)I tried setting Intent.FLAG_ACTIVITY_CLEAR_TOP for intent but it does not help.
Let me know what I am doing wrong.
I have an application in which I want to show a custom activity(Access Denied) when user try to share an image.
When I am trying to share an image from default 'Downloads' application (For eg: share image through default message/gmail application) the custom activity is showed and exits 'Downloads' application.But next time when I launch the 'Downloads' application and press on an image the previously created draft mail/message is shown as the top activity.So it shows the custom activity always.
Launched the 'Downloads' application by using this intent.
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(new ComponentName(packagename,className));
startActivity(intent);
How can I fix this? I want to launch the 'Downloads' application as new (removing history of gmail/message etc.) every time.
Please try below code
Intent intent = new Intent(ClassA.this, ClassB.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);