I'm trying to programmatically call an event to launch an application in Windows Phone 7. How do I go about doing this?
What I'm looking for is how do I schedule this event call? (for example, opening an app in WP7)?
I think you are talking about Tasks. All available tasks can be consulted here: http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks(v=vs.92).aspx
The call app you are talking about is the PhoneCallTask: http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.phonecalltask(v=vs.92).aspx
If you want to call and app, that is, to open an application from the phone, you can't really do it. Please look at: Launching other applications in Windows phone 7 Programatically
Related
I modified my Windows Phone 8.1 application (universal app with just the Windows Phone project live yet) to have a VoiceCommandDefinition (VCD) file in place and this works fine to start my app in foreground mode and handle parameters.
But I want to let my app quickly answer some app specific questions like it is described in this blog for Windows 10. I have tried to apply this blog but the app manifest modification fails. It does not know the:
uap:AppService
When I looked it up, it seems to be available for Windows 10 only. So I searched up the internet mainly MSDN and stack overflow, but I could only find examples that run the app in foreground.
Does anyone know an example how to provide answers to the Cortana content page with a background service?
Only App service can meet your requirements.
But App service is new in Windows 10, so you cannot use uap:appservice in Windows Phone 8.1 application. You can see App to app communication video from 26th minutes which introduce the app service.
So you can use universe windows app to develop. Sample is Cortana voice command sample as you see in that blog.
I'm working on creating custom Cortana commands. The commands are registered and executed using a Universal Windows Platform Application. (GitHub)
For instance, I've registered the following command
<Command Name="ShutDown">
<ListenFor>Shut down</ListenFor>
<Navigate/>
</Command>
To run this function in a UWP application
static async void ShutDown()
{
var dialog = new MessageDialog("This is where I would shut the computer down.");
await dialog.ShowAsync();
//System.Diagnostics.Process.Start("Shutdown", "-s -t 10");
}
But after setting this up I learned System.Diagnostics.Process isn't supported in UWP.
The custom commands I want to run involve some sort of execution such as launching external programs, running other scripts, or opening websites.
It makes sense that UWP doesn't support them given that it's universal and an XBox or a phone might not be able to do these, but I was hoping there was some alternative or hacky way to accomplish this on a Windows 10 PC.
Is there a way for me to execute Process commands or something else with similar functionality in a UWP application? It seems like even though I can get Cortana to execute my C# code, UWP doesn't support much that would be useful in this situation.
Thanks in advance.
There are - limited - ways to achieve similar behavior.
You could use LaunchUri to trigger other apps which registered for a certain URI-Scheme. This should work for your webbrowser scenario. More details here:
https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.launcher.launchuriasync.aspx
You could trigger another app and get results back from it using LaunchForResults. The called app has to support this. More details here:
https://msdn.microsoft.com/en-us/library/windows/apps/mt269386.aspx
You could trigger App Services provided by another app. The called app has to support this. The app service will be executed in background. ( I think this is pretty cool.) More details here:http://blogs.msdn.com/b/mvpawardprogram/archive/2015/06/11/writing-windows-10-app-services-in-javascript.aspx
This is a little hacky: I'm not sure if this still works but it did work for Windows 8.1: You could create a so called "Brokered Component". This allows you to trigger everything from you app on you machine, but you won't be able to publish a brokered component into the store. This also allowed Process.Start() on Windows 8.1. It only worked for sideloaded apps. I'm not sure if it still works on Windows 10.
More info here: https://msdn.microsoft.com/en-us/library/windows/apps/dn630195.aspx
Summary:
Starting another app is pretty easy as long as the target app registered as app service or registered a protocol handler (Uri scheme).
Starting scripts or other *.exe is impossible if option 4 doesn't work any longer.
With the Windows 10 Anniversary Update (1607) there is an option to enable this scenario on PC. With this API in the Desktop Extension SDK you can launch a fulltrust process that runs at the full user privileges:
https://learn.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.FullTrustProcessLauncher
This way you can light it up on the platforms where it is supported, i.e. PCs running 1607 or above. And your app will still be universal:
if (ApiInformation.IsApiContractPresent("Windows.ApplicationModel.FullTrustAppContract", 1, 0))
{
await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
}
Is there a way to shut down the device by calling a method in c#? And if yes, an example would be nice. Be aware of that i'm asking if it's possible in a windows universal app.
You can NOT shut down the device with a windows universal app.
I'm working on a Metro style application in the new WinRT (.NET 4.5) framework for Windows 8, and I was wondering if it would be possible somehow for an application (through the registry or some other means) to register itself to start up when Windows starts as well.
I haven't been able to find anything about this anywhere else, only for Windows 7 or below, with normal-style applications.
There is no way to make a Metro style application launch at boot. The user will have to invoke the application from the start screen. Metro style applications cannot be services and so launching them at boot time doesn't seem like the right approach any more than launching Microsoft Word or Adobe Photoshop at boot time would be.
Microsoft's goal with Metro-style apps is that the user is always in control. Therefore, Metro-style apps cannot activate themselves when a machine boots up. Furthermore, traditional Win32/.NET desktop code cannot interact with Metro-style apps and so cannot start a Metro-style app behind the scenes.
That said, if your app has registered itself as the handler for the rendering of its own tile, then it gets called periodically and is asked to re-render its tile's content so it should always be able to show its latest status/news/info to the user when they view their start page.
I think you could have all your star tup stuff running as a service that exposes the appropriate WinRT level connectivity. Then the user only needs to fir up the client app.
Goo separation too.
I am trying to start a windows application from a windows Service using the below code
Process.Start(#"filename.exe");
In windows 7 I receive a popup that says, "A program running on this computer is trying to display a message"
You cannot start an interactive application from a Windows Service. This was changed in Windows Vista and 7.
Some other advice was given in this Stack Overflow answer on the same subject.
When I've needed to do this, I had to change my Windows Service to a Console Application, and invoked it in that manner.
A work-around I found for this issue was to use the windows task scheduler. You can schedule the application to run some amount of seconds later by creating a batch file.
At my previous company we had this issue and we wrote a console app that ran in the sys tray and acted as a bridge from the service to the desktop. Basically via remoting (I'd use WCF now of course) we let the service request that the console app start up another application.