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.
Related
I have a problem with a feature of my application.
I need to open external files to display them like .jpeg or .xls for example. For that I use Intents to open them with the default system application and it works fine.
But in a case where we will first open a document, for example a photo. this will display in the default app and then I go back and forth in my app. Everything is OK
But then I'm going to open another standard .xls document, it'll open the document in the appropriate application and going back will show the opened image first and not my application again.
I don't understand why it happens like this.
What I would like is that when we do previous in a file viewer app, the app quits and doesn't stay in the ActivityManager.
Is it possible ?
I have already tried some intent flags but without success.
My code here :
Android.Net.Uri fileUri = FileProvider.GetUriForFile(Android.App.Application.Context, "com.app.fileprovider"
, file);
Intent intent = new Intent(Intent.ActionView);
intent.SetData(fileUri);
intent.AddFlags(ActivityFlags.GrantReadUriPermission);
intent.AddFlags(ActivityFlags.NewTask);
intent.AddFlags(ActivityFlags.NoHistory);
Android.App.Application.Context.StartActivity(intent);
return true;
Thanks a lot for the help
Max B
SO !
My bad, It was not a real problem.
It was a design error.
Indeed during my call of my function to call the intention I linked my opening event without then unbinding it. So that with each call I recalled X times my file opening function without ever destroying my variable or my variable instance.
The Intent Works Well
Thanks for the comments
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.
var uri = Droid.Net.Uri.Parse(url);
var intent = new Intent(Intent.ActionView, uri);
intent.SetFlags(ActivityFlags.ClearTop);
StartActivity(intent);
(Code is xamarin)
This code will open a page that is actually download of a PDF. After the file is downloaded, chrome will close the tab and show the last tab the user was looking at and pressing back will just continue to move back in chrome, not going back to the app.
Can it be done that when the file is downloaded user is returned to the app instead of being in chrome (or other browser)?
If you use ActivityFlags.NewTask you will get the desired effect. Only issue with downloading file is that the tab that downloads a file will close and you will get the tab that was opened before it, but if you press back button it will go back to your app.
In my android app, I create an intent to display an image in the photogallery app.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file:///storage/sdcard0/arin/category/1/1.png"), "image/*");
context.startActivity(intent);
This opens the photo app and shows that image but only that image...
I know there are other images in the same folder. But the app wont let swipe left/right and switch images. How can I change the code so it will let me see the other pics in the same folder...
Thanks
How can I change the code so it will let me see the other pics in the same folder
Write your own "photogallery" code.
There are hundreds, perhaps thousands, of apps that are capable of responding to your Intent. None of them have to offer any means to "swipe left/right and switch images". If you want a specific set of behaviors, write them yourself. If you want the user to be able to view the image in the user's chosen app, then stick with your existing code and do not worry about the behavior of the user's chosen app.
I have an app which wants to view an image in the gallery app.
I use this code to view it:
File cachedImage = cache.getFile(image.getImageUrl());
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(cachedImage), "image/*");
startActivity(intent);
This works except when I click the edit setting here:
and I get the no apps can perform this action message:
Is there some way to make this work? Do I need to pass additional extras? I know the Gmail app is able to view an image attachment in the gallery and the edit function works. This is on JellyBean.
Is there some way to make this work?
Install an app that can edit pictures. Your screenshots appear to be of the Gallery app, which is presumably trying to use ACTION_EDIT to start an activity to edit the picture, and there is no such activity available.