Windows Phone 8.1 Voice Commands App Activation - windows-phone-8

I want to integrate some voice commands in my windows phone 8.1 app.
The first thing I want to do is to open my app by a voice command and navigate to a certain page.
According to MSDN article Quickstart: Voice commands (XAML) I can use the override of protected virtual void OnActivated(IActivatedEventArgs args) method in App.xaml.cs to meet my requirements. But it does'nt work the way I though it would!
I have the method with the following structure:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.VoiceCommand)
{
var commandArgs = args as VoiceCommandActivatedEventArgs;
if (commandArgs != null)
{
// ... some logic here
}
}
}
The problem is when I'm activating my app by saying "Open 'name of my app' [optional words]" the app opens but the Activated event never fires! The app opens and OnLaunched event fires. So I can't even enter the OnActivated method.
Does anyone know the problem? Why can't I enter OnActivated method using voice commands?
P.S. I tried it with a simulator as well as with a real device.

you can see this article,
http://t.co/Q5hRxRPvwR
is in spanish, but you will understand.
After you install the app and run it, the xml should be installed, like said in documentation.
After ask to cortana "What can I say?" it will show all you can said, and the apps that supports cortana. Choose you app and you will see what you can say for your app, like
If you say what your app can listen, your app will be activated.

Related

How to launch a windows store 8.1 app from a browser in with a url and pass some data to the app?

Hi am developing a Windows store 8.1 app using C# and xaml. I get the some configuration settings in my mail with a URL, which are lets say host address, port number, and some app id. When i click on the url it should open my app and fill the settings in the app(Defaultly am launching Configuration page in my app which contains three textboxes, those three values should pre populate here)
Is it possible to do it Winrt 8.1? If so how can i achieve it? Can someone please help me out to solve this?
Thanks in advance
First you need to handle URI activation.
In your manifest, add a Protocol and reserve a Name(here is alsdk). You can refer here for more information.
Then please override OnActivated event in App.xaml.cs (receive params here).
public App()
{
this.InitializeComponent();
this.Suspending += this.OnSuspending;
}
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
// Retrieves the activation Uri.
var protocolArgs = (ProtocolActivatedEventArgs)args;
var uri = protocolArgs.Uri.ToString();
}
}
After that you can launch your app with params in the browser:
As for passing params,please refer here.

Wait for App to idle after Interruption

I have a ViewController that will request access to location services on init via
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined)
{
[_locationManager requestWhenInUseAuthorization];
}
This triggers the "Allow app to access your location while you use the app?"-alert.
I use [self addUIInterruptionMonitorWithDescription:handler:] to react to this. I am encountering the following problem: after dismissing the request-dialog, the ui-test does not continue. The alert is dismissed, but Xcode waits for the app to become idle, but it looks like the app is idle:
t = 67.35s Wait for app to idle
The test fails, because the app is stuck here. If i tap into the simulator, Xcode logs.
t = 72.27s Synthesize event
and continues the test.
Is there a reason, why Xcode tries to wait for the app? A workaround seems to be to tell Xcode that the UI changed or an event happened. Is there a way to trigger this?
After presenting the alert you must interact with the interface. This is a known bug with Xcode 7.2. Simply tapping the app works just fine, but is required.
addUIInterruptionMonitorWithDescription("Location Dialog") { (alert) -> Bool in
alert.buttons["Allow"].tap()
return true
}
app.buttons["Find Games Nearby?"].tap()
app.tap() // need to interact with the app for the handler to fire
XCTAssert(app.staticTexts["Authorized"].exists)
See my blog post for more information.

ApplicationClose event

I'm developing Windows 10 universal app in C#/XAML.
I want to implement such a policy, that whenever user closes my app (and some other conditions are met, but its irrelevent here) an adverisment will display.
My question is how can I intercept and cancel/handle an event when application is being closed? This is easy when user decides to close the app by for example pressing a button that I'll define in XAML, but what if he presses Alt+F4? In Winforms this is easy as well:
private void Form1_Load(object sender, EventArgs e)
{
this.FormClosing += Form1_FormClosing;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}
But how can I achieve similiar effect in in Windows 10 universal app?
I'm afraid there is no option to cancel the closing of the app or even delay it. The Suspending event is the only indication your app will receive prior to termination (if it happens). Check out the Application.Suspending event: https://msdn.microsoft.com/en-us/library/windows.ui.xaml.application.suspending.aspx
No, you can not achieve the similar effect in Windows 10 Universal App (and Windows 8.1 Store App), because in the modern app, the user have the full control of the app and the app can not stop the user closing a app.
If you have sth need to handle when user closing the application, as Lukkha stated, you can handle them in Application.Suspending, but there is a time limitation by default, all of the things should be done within 5s. If you want to have more than 5s, you need to request a ExtendedExecutionSession.
Using Extended Execution in Windows 10 Universal Apps

Windows Phone Custom URI

in my windows phone 8 application i am using custom uri association to launch another application through my phone.
i.e
await Windows.System.Launcher.LaunchUriAsync(new Uri("sixtag:"));
but my app is not able to get certified for store because of this. the testing team tells that you app terminates unexpectedly while executing this.
now, i don't know how to deal with this.
is there any way to throw exception if the app which i am launching is not installed on phone ?
or i should try something else so my task gets accomplished and app gets certified for store as well.
You do not need to wrap your launch in try/catch or check for success as described in the other answers. As soon as you call LaunchUriAsync, the platform takes over and will automatically handle the possibility of no app being installed by asking the user if she wishes to search in the store.
A couple of things to double-check:
1) Ensure that you can successfully back into your app following the navigation to sixtag.
2) Ensure that your call to LaunchUriAsync is the direct result of a user action (eg. tapping a button)
try
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("sixtag:"));
}
catch
{
MessageBox.Show("please install Sixtag from the app store","AppMissing", MessageBoxButton.OK);
}
you can perhaps display another button and on clicking directly navigate to the app store. See if this solves your problem. Do vote it up if it does :)
You are needed to handle that as shown here . Also Read out Remarks given there.

Using App.Current.Terminate() method in Windows phone 8

As windows phone 8 provides us with this method for programmatically terminate an app, will there be any issue while app submission if we use this in app for terminating a page while there is no backentry in the navigation history?
There won't be any issue in certification when using this call, but make sure you have saved all data in your app when calling this, because this call effectively kills your app immediately - ApplicationClosing even handler won't be raised after it!
Why would you call Application.Terminate when navigating back with an empty back stack? Just let the app close itself. Seems a bit pointless to me to overuse Application.Terminate().
I can't say much about the new Terminate method, but I do have an app (NOTE: Not a game) that does the following at certain points
private void Kill()
{
new Microsoft.Xna.Framework.Game().Exit();
}
This app passed certification without any problems. This was an app for both WP7 and WP8 so I did not have the ability to use Terminate().