So i'm opening a standalone Unity app from a UWP store app. In my UWP app I use the unity WSA class to launch the custom uri I created.
Example:
In the register I created a custom uri called test:
In UWP app c# I use:
string uri = #"test:";
// Launch the URI
Launcher.LaunchUri(uri, true);
This works fine. The app launches. However if the app does not exist it pops up a dialogue to ask me with what I want to open it. Can I check this also while launching? So if the user has the app not installed I give the user feedback? I tried pretty much every class available for Unity and uri's etc. None of them do what I need. I had high hopes for a few, but all they did was tell me if the URI i entered are valid uri formats, rather then checking if it can actually open the app.
EDIT: Also, what's the difference between Launcher.launchURI and Application.OpenURL?
Application.OpenURL opens a url in the default browser, while Launcher.LaunchUri starts the default app associated with the specified URI.
And no, from the UWP app you just can’t query the system whether the URI is registered or not, there is no such API.
And LaunchUri just returns false if no app is launched, but at that time an error dialog is already prompted, so checking the return value of LaunchUri is not a solution either.
Related
So just like uTorrent gets magnet links and opens them,
How can I setup my WinForm app to get a URL from Default Browser (in this case my default is Chrome) and open that URL in EO.WebBrowser within my app?
I don't have any code for this yet, as I don't know where to start.
Is this something that would be assigned as a Registry Key?
I know there are Registry keys for uTorrent to handle Magnet links in HKEY_CLASSES_ROOT\Magnet\shell\open\command.
What I have is WhatsApp Web open in EO.WebBrowser, and when I click on a URL starting with https://web.whatsapp.com or https://api.whatsapp.com it would open that link. The thing is the link should be changed to web.whatsapp.com, instead of api.whatsapp.com
I'm trying implement Facebook Login using the Facebook C# SDK but I'm having an issue returning back to the app when a login has been successful.
I have followed all the steps in this tutorial but i'm having an issue.
I have created a custom UriMapper that should go back to the MainPage.xaml when launched.
public override Uri MapUri(Uri uri)
{
if (uri.AbsoluteUri.Contains("/Protocol?encodedLaunchUri=msft"))
{
return new Uri("/MainPage.xaml", UriKind.Relative);
}
return uri;
}
My problem is the page refreshes and all my data in forms and text boxes gets removed.
Is it possible to "Resume" an app via URI instead of restarting it?
I've tried adding the tag below in the manifest but this does not work.
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" ActivationPolicy="Resume"/>
The part that you added in the manifest file enabled Fast App Resume, which means that your application won't be relaunched as a new instance if it is sitting in the background. But this doesn't guarantee that your input boxes will get their data restored. For this, you need to preserve the page state and restore it when the app resumes. Read more about this here.
The question says it all. Basically, I just want to know the alternative for this in WinRT:
Process.Start("http://www.google.com/");
In WinRT, you can use Windows.System.Launcher.LaunchUriAsync to launch the default app associated with the specified URI. For a web link, the default browser would be used.
MSDN: Launcher.LaunchUriAsync(Uri) | launchUriAsync(Uri) method
You can use Windows.System.Launcher to launch files and URL's...
Windows.System.Launcher.LaunchUriAsync(Uri) will launch a given Uri with the default application. If it's a link it will open with default web browser. You can use file:/// scheme to open an network resource, but not resources on the local file system.
Windows.System.Launcher.LaunchFileAsync(IStorageFile) will launch the default application for the given file.
Both that methods has an optional second parameter of type Windows.System.LauncherOptions that customizes the launch.
I need to launch a browser, do some work and then make the browser navigate to a URL (in that order).
The first part is of course simple and I have a Process object. I am at a loss as to how to later direct it to the target page?
How do I treat the Process as a browser and make it navigate to the desired page?
Any help, pointers, code snippets appreciated.
Instead of launching the browser & then navigating to the page, just tell the OS that you want to run the URL. Windows will pick the correct browser, and navigate the user to the given URL.
System.Diagnostics.Process.Start("http://www.StackOverflow.com");
If you don't need to do this in production, you could use a testing library such as WatiN to do this:
using WatiN.Core;
//Placeholder page to launch initial browser
IE ie = new IE("http://www.google.com");
DoSomeWork();
//Now navigate to the page you want
ie.GoTo("http://stackoverflow.com");
My first instinct for this question was DDE, but it appears that has been decommissioned in Windows Vista so that is no good. Shame, as it was the only consistent mechanism in Windows for Interprocess Communication (IPC)...oh how I miss Arexx on the Amiga.
Anyhow, I believe the following will work but unfortunately, due to the way it works, it launches Internet Explorer irrespective of the configured browser.
If your application has a Form, then create a WebBrowser control on it. Set this to non-visible as we are only making use of its as a launching device rather than to display the web page.
In code, at the point where you want to show a web page, use the following code:
webBrowser1.DocumentText = "window.open('How to launch a browser and later direct it to a page?', 'BananasAreOhSoYummy');";
What this does is to tell the WebBrowser control, which is just the IE in disguise, to open a new window called 'BananasAreOhSoYummy'. Because we have given the window a name, we can use that line repeatedly, with different URLs, to change the page in that particular browser window. (A new window will be opened if the user has happened to close it.)
I will have a think about an approach that honours the user's default browser choice.
If you don't need the actual instance of IE, you can use the System.Windows.Forms.WebBrowser control.
I think instead of sending the browser a url you could send it javascript that would run and direct the browser to a site.
Not sure if this would work but I see no reason why it wouldn't
I need to launch a media file from a URL from within my c# .NET application. Is there any way to do this natively in .NET? I don't need an embedded player, I just need the default player to launch. I have tried
System.Diagnostics.Process.Start("File URL");
but it launches the default browser and downloads the file, instead of attempting to play it in WMP/VLC/whatever the default media player is. Any ideas?
If you enter an URL it will be handled with the program registered to that URL format, in your case the default web browser.
What format are the media in? You can get associated program for an extension and then run that program with the url as parameter.
See:
Windows: List and Launch applications associated with an extension
So if your media is for example .MP3, then find the assoicated program for .MP3 (using the code in the link above) and pass the url as a parameter to that program.
Another way to handle this is to temporary download the file to the local file system and then run your
System.Diagnostics.Process.Start("Local File");
Then it should work as you expect.