Launch One metro app from other Metro app Windows 8 - c#

I am working on a project in which i have to integrate other apps/games with my platform. Through which i can run them. So their is one bad test solution is that i make them hardcodedly integrate them inside my framework as a part of framework. But that is crap.
So, my question is can i run other installed apps(these apps will be downloaded from store separately) through some code from my platform and I know data can be transfer from one app to other apps.
It should be like when i click on Play App Button then an installed app will get start and i transfer some settings to it and when user finish playing that app some data get transfer back to my platform and my platform resumes to corresponding state.

For opening other app form your app you have to know the uri for the app for example You want to open "another app"
string anotherappURI = "anotherapp_uri_value:///?anyVariable=value";
Uri uri = new Uri(anotherappURI);
await Launcher.LaunchUriAsync(uri);
And if you want to make a uri for your app so that it can be open from another app please follow the steps
Double click on package.appxmanifest file in the project
In the Declaration tab, select "Protocol" in the drop-down list and click on add
Enter "your_app_URI_displayname" as Display Name and "your_app_URI" as the Name
Save these changes
Now after activation (when your app is called and opened) how get the activation
Go to App.xaml.cs file
Override the OnActivated method
Insert this piece of code within :
Code:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
ProtocolActivatedEventArgs eventArgs = args as
ProtocolActivatedEventArgs;
// TODO: Handle URI activation
// The received URI is eventArgs.Uri.AbsoluteUri
}
}
NOTE: Please upvote and accept it as answer if helpful

Related

How to input filepath into Console App on Mac when using Automator Quick Service

I've been using Windows in my audio/video production company. I've created a few Console Apps in C# that make a POST request to our Transcoding server. Through the Registry Editor in Windows I was able to create a right-click menu option and feed the path as Command Line Argument to my Console App. The app picks up the filepath, does some checks and the executes the POST request.
Since we're on Mac now, I'm trying to rebuild this functionality. I noticed the easiest way to create a right-click menu option is to build a Quick Service in Automator.
I've Set the Automator workflow to 'Workflow recieves current files or folders in any application. Then I'm using this AppleScript to fire up the Console Application:
on run {input, parameters}
tell application "Terminal"
do script "/File/Path/To/MacRightClickTest"
end tell
end run
The Console App runs this test code:
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine("Script Started!");
foreach (string arg in args)
{
Console.WriteLine(arg);
}
Console.ReadLine();
}
}
The Terminal does show 'Script Started' but does not show anything else.
How can I input the right clicked file(path) into my Console App on Mac? Can I use the input parameter in the AppleScript in some way?
Any help in the right direction will be appreciated.
Thanks!
Erik

How to use Geolocator.RequestAccessAsync in WPF desktop app

I've built a WPF app in C# which needs to know the user's location, and currently requires that it be entered manually. I'm using the Desktop Bridge to make it be able to run as a UWP app. When it's running as a UWP app, I want to take advantage of the Windows 10 location API if it is enabled. I'm using the following code to request for location access when the program starts:
public static async void RequestAccess()
{
var accessStatus = await Windows.Devices.Geolocation.Geolocator.RequestAccessAsync();
switch (accessStatus)
{
case Windows.Devices.Geolocation.GeolocationAccessStatus.Allowed:
UwpDesktop.hasLocationAccess = true;
break;
case Windows.Devices.Geolocation.GeolocationAccessStatus.Denied:
UwpDesktop.hasLocationAccess = false;
break;
case Windows.Devices.Geolocation.GeolocationAccessStatus.Unspecified:
MessageBox.Show("Failed to access Windows 10 location API", "Error");
UwpDesktop.hasLocationAccess = false;
break;
}
}
However I get the following error when I run my app if the location permission is not enabled for it:
System.Exception: 'Element not found. (Exception from HRESULT: 0x80070490)'
The cause of this error as far as I can tell is that the RequestAccessAsync function needs to be run in the main UWP UI thread. The reason it only happens when the location permission is not enabled is because Windows tries to launch a UWP dialog requesting that the user grant location access, but fails to do so in a Desktop Bridge app.
I'm aware of two solutions to this problem. One would be to launch the Location section of the Settings app and show a messagebox to users asking them to grant location access there, which could work but I would really prefer to use the official API. The other option is to create a new UWP code project and write this code there, and then run it from the WPF app.
Microsoft has some documentation that is supposed to explain how to do the second option, but their examples are complicated and I don't know how to apply them to what I'm trying to do. I don't want to create a XAML UI or a background service, all I need is a way to safely call RequestAccessAsync and return a value based on the outcome. I'm wondering if I really need to create a UWP project to make this behave the way I want, or what the simplest way would be to go about it.

UWP app can't fully launch another UWP app?

The UWP app I'm working on uses Launcher to launch another UWP app that I also wrote. Here's the code I'm using to launch the other app:
var uriToLaunch = "testapp-mainpage://";
var uri = new Uri(uriToLaunch);
bool success = await Windows.System.Launcher.LaunchUriAsync(uri);
So far, this code is able to launch the other app I wrote, but it just opens up the app window with the default blue background with an X in the middle, basically the default UWP splash screen. I've tried setting the URI to target the MainPage of the app, but no matter how I try to modify the URI, it just launches to the default splashscreen. The app I'm launching is just a very basic, default UWP app at the moment. What am I missing or doing wrong that it the app being launched doesn't fully initialize?
You need to modify the launched app to handle protocol activation. The default wizards generate an app.xaml.cs which handles typical activation via OnLaunched but not alternate activations via OnActivated:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
// TODO: Handle URI activation
// The received URI is eventArgs.Uri.AbsoluteUri
// You'll likely want to navigate to a page based on AbsoluteUri
// If you just want to launch the main page you can call essentially
// the same code as OnLaunched
}
}
See Handle URI activation on MSDN for more details. See the Association Launching Sample for a concrete example.

Reinstantiation issue using Inter App Communication with Windows Phone

I am developing an WP8 app that uses a webbrowser control that shows statefull server content. On WP8 you can switch between apps manually. E.g. if you want to copy&paste some information from one app into a browser input field. If you switch that way, the current app instance stays alive. That means the web session and the current page of the browser control will stay available.
Now I want another app to send some data directly into the app with the browser control - without restarting it...
From what I know, there are three ways to handle inter app communication:
register a file type that will open the app by launching that file from local storage
register an app protocol and use Launcher.LaunchUriAsync() to submit parameters in a query string
use a shared storage file
Detailed information can be found here.
I think the last approach is not usefull, because after you have started the second app, there is now way to activate the calling app or is there any usefull way to reactivate the webbrowser app?
I tried the second approach, but I am running in an issue, because it starts a new instance by design. That means InitializePhoneApplication is called. There is the entry point for the custom UriMapper that reads the incoming parameters. So the old app instance is killed and all session data, cookies and input fields are gone. With WP webbrowser control you are not able to store the cookie and page state, so a fast app resume is not possible also.
private void InitializePhoneApplication()
{
if (this.phoneApplicationInitialized)
{
return;
}
RootFrame = new TransitionFrame();
RootFrame.Navigated += this.CompleteInitializePhoneApplication;
RootFrame.UriMapper = new AssociationUriMapper();
//...
this.phoneApplicationInitialized = true;
}
Is there any other way or a possibility to use the shown approaches to send data between apps without restarting them using LanchUri()?
That means, to send some data back to a running instance without reinitializing the whole app, so that the page state and session state are still available on the target app.
Best regards
Holger
FastAppResume is the solution. I haven't used it and thought it also reinitiates the app. But it doesnt. This example shows how to reuse the existing instance.
Regards
Holger

LaunchUriAsync() doesn't launch Windows Store App

I'm trying call my application on OnShareTargetActivated() method by LaunchUriAsync() but it doesn't work.
I have a protocol called "myapp" in appmanifest. When I put "myapp://test" on File Explorer, my application is launched, but when I do it:
protected async override void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
{
Uri uri = new Uri("myapp://test");
await Windows.System.Launcher.LaunchUriAsync(uri);
}
This occurs when the user clicks on my application that is on Charm Bar in Share option. But the application is never launched.
sharing app sample (http://code.msdn.microsoft.com/windowsapps/Sharing-Content-Target-App-e2689782)
You should check the format , of what you are sharing , metro will only accept some type of content to share , Sharing format are Text,uri,Bitmap,storageitems,Html
share target code and pictures (http://blogs.msdn.com/b/going_metro/archive/2012/05/03/integrating-with-windows-8-share-charm-part-1-receiving-data.aspx)
if u find useful , pls acccept as answer

Categories