How can I open an image in the default photos app? - c#

I have an app that captures images from the device's camera and saves them as StorageFiles to a folder in my app's roaming data. I've been trying to make a page that will open the image and show a preview, but I've been having many problems doing that, so I want to just open the image in the default photos app. However, I can't find any way to do that. Using await Launcher.LaunchUriAsync(new Uri(#"ms-appdata:///roaming/folder/img.jpg")); asks if I want to search for an app in the Store (searches for "ms-appdata"). Does the native Photos app for Windows (Phone) have a dedicated URI scheme? Also, I am targeting Windows 10 with this app, so the URI schemes (if any) may have changed.

Launcher.LaunchUriAsync is for launching an application using the URI scheme, this is not what you want.
Instead you'll want to launch an app based on a file:
Get the image as a StorageFile
var imageFile = await StorageFile.GetFileFromPathAsync(#"ms-appdata:///roaming/folder/img.jpg");
Then you tell the OS to launch an app to handle that file. It's then up to the user to choose which app to handle the image file:
var success = await Windows.System.Launcher.LaunchFileAsync(imageFile);
You can read more about "launching" files here.

Related

Open iOS 11 Files app and display my app's Documents folder

My app stores some apps in the Documents folder. The user can see these files by opening the the built-in iOS app called "Files" and selecting "on my iPhone" and the name of my app. Now I'd like to open the "Files" app programmatically. This will save the user the steps of going to the home screen, tapping the "Files" icon and navigating to my folder.
I found this question Open iOS 11 Files app via URL Scheme or some other way that seems to do exactly what I want, but it is in Swift and I was not able to translate this to C# myself.
What is the C# way of the same thing as in the above question?
you can open the Files app with the scheme shareddocuments
var url = new NSUrl("shareddocuments://" + Uri.EscapeDataString(folderPath));
UIApplication.SharedApplication.OpenUrl(url);

Create Cross-Platform Application (Android, iOS) as an option to open PDF documents

Hello,
I've developed an Android application in Java for creating electronic signatures upon PDF documents. To run the application, the user should choose a PDF document from stored documents and after the Open With picker prompts, the user should choose the developed application and the application starts. In Java I managed to do that by setting an intent-filter (with mimetype set for application/pdf) in the Antroid Manifest file of the project. I want to do the same thing in a Xamarin.Forms cross-platform application. Is there any way to achieve this?
This is possible through official Xamarin.Essentials:
https://learn.microsoft.com/en-us/xamarin/essentials/launcher?context=xamarin%2Fxamarin-forms&tabs=android
This features enables an app to request other apps to open and view a
file. Xamarin.Essentials will automatically detect the file type
(MIME) and request the file to be opened.
Here is a sample of writing text to disk and requesting it be opened:
var fn = "File.txt";
var file = Path.Combine(FileSystem.CacheDirectory, fn);
File.WriteAllText(file, "Hello World");
await Launcher.OpenAsync(new OpenFileRequest
{
File = new ReadOnlyFile(file)
});

Launching files from path in Windows 10 UWP

I have tried to launch a file from the computer in many ways, suppose is d:\a.pdf
1.- Tried with Launcher.LaunchFileAsync but needs StorageFile that should be GetFileFromPathAsync but as everybody knows W10 apps are unauthorized to open such that path.
2.- Tried using file:/// like file:///d:/a.pdf but it simply returns false
var success = await Launcher.LaunchUriAsync(new Uri("file:///d:/a.pdf", UriKind.Absolute), options);
3.- Launcher.FindFileHandlersAsync() neither returns empty.
So is there any way to launch files?
There is no way to launch files from paths that the app doesn't have permissions to read. Apps don't have access to d:\
You can use LaunchUriAsync to launch files by path from within the app package or app data directories, but not elsewhere. Using the ms-appx: or ms-appdata: protocols is a cleaner way to address those locations.
If you have permission then you can get a StorageFile. This will allow launching files from libraries, locations chosen via FilePicker, files clicked on to launch the app (though that would be circular), etc.

open specific file in appropriate app from inside Windows 8 App

I'm creating Windows 8 app in which i need to list specific files in a page and then let user open that file. I'm using C# as backend.
I want to ask this (as in the image below), to my user when they try to open any app listed in my app page.
when user select specific app, then the file that is clicked should open in that app.
Unlike previous versions of Windows, the User is now in control of file associations.
To show the launch using the Window above, you can refer to the complete example of launching options here.
The core of it is deciding on a Point on the screen (which is openWithPosition in the example below) and then calling LaunchUriAsync with the options set to display the window.
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
options.UI.InvocationPoint = openWithPosition;
options.UI.PreferredPlacement = Windows.UI.Popups.Placement.Below;
// Launch the URI.
bool success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
The linked example code contains a function that can compute a reasonable Point given a XAML element.

windows phone 7 Download files and save it in phone storage

am developing an application which can fetch files from internet.. how do i download and save a "docx" or "wav" file from internet within the application and use it later with other application likes office or windows media player.
You can download files in the background (ie. they will continue even when your application is not running).
Having said that, you should research the types of files you need to support. For example, you can play an audio file (if the format is supported) or add it to Music hub but you cannot open a file in Office. Very few filetypes can be integrated with, so do some research before you start writing your app otherwise you might be disappointed.
place an image control in your page. here im1 is controls name.
it is working for me
string imgurl="http://.........";(path)
Uri addrs=new Uri(imgurl,UriKind.Absolute);
BitmapImage bitmap = new BitmapImage(addrs);
im1.Source = bitmap;

Categories

Resources