In my app (WP 8.1 RT) I use the DataTransferManager to share content. After launching the sharing UI, the app returns back to the page(2nd page of the app). And then, when I press the back button it's suppose to go back to the previous page(MainPage) but instead, its exiting the app. Back buttonn is working properly before launching the sharing UI. And this doesn't happen when debugging.
This is the order of the events happening.
Page1(main) -> Page2 -> (Calling DataTransferManager)SharingUI -> Backto Page2. Then back button exits the app.
What could be the cause?
I can't reproduce this issue. How do you handler back button pressing? Try using NavigationHelper instead of using custom BackPressed handler. I hope it will help you.
Related
I am developing an app based on a mobile website which runs inside a Windows Runtime WebView for Windows Phone 8.1. Currently, I am looking for a way to catch link clicks in the app's webview which start with a certain pattern. In the Windows Phone Silverlight version, the following was possible:
In my webview I display links like this
Do something in the app
Do something different in the app
In the app, I catch a click on such a link with the following code
MyWebView.Navigating += HandleOwnStuff;
void HandleOwnStuff(object sender, NavigatingEventArgs e) {
String url = e.Uri.ToString();
if(url.StartsWith("ownstuff:")) {
// check which function has been called and do something in the app, e.g. open the camera
}
}
Unfortunately, this approach is not possible in a WinRT app any more. Whenever I click such a link, the launcher opens with the message "Search for an app in the store".
The "NavigationCompleted" handler of the WebView is not called - this link click is catched before any handler of the WebView is called.
An approach which would work is using the UnsupportedUriSchemeIdentified handler, which - unfortunately - is only available starting from Windows 10 in UWP.
Another solution would be to completely rewrite my website so that the ScriptNotify handler can be invoked - which would be way too much work, since the website now also runs in normal browsers, Android and iOS devices - so this approach is definitely not worth the trouble.
Does anyone know a solution? Thanks.
I have talked about this with MSFT for awhile. Your right, with win10 that's why that event was added. The best way to workaround it is to change the website.
I am developing 2 apps in WP 8.1.
One should send requests(I call it "sender") and the other one should answer on them (I call it "receiver"). Both will be installed on the same WP device.
The perfect solution will be the one that user will not see in the UI that some "communication" is happening with different application.
But no matter how I try, the turnstile animation is displayed whenever "sender" hide/get visible.
[I removed splash screen, set transitions to null. However even if I close the receiver immediately (after the LaunchUri was called) I still can see the turnstile animation]
Imagine this example:
"sender":
User will click on "test button" and this code will be called:
await Launcher.LaunchUriAsync(new Uri("myreceiver:giveMeYourSecret"));
in "receiver"
as the answer on this code:
await Launcher.LaunchUriAsync(new Uri("mysender:MySecretPassword"));
and closes itself.
in "sender":
MySecretPassword is displayed in some TextBlock.
I know that this example is nonsense. I just need to achieve communication between 2 apps without any "not-wanted animations"(like turnstile).
My Questions:
Is there another way how to communicate between 2 windows phone 8.1 apps than via LaunchUri?
Is it possible to remove turnstile animation when the app is being resumed/deactivated ?
Thanks for any suggestions :)
In WP7 and WP8 I just needed to clear the backstack in a page, then press Back button and the app is closed. In WP8.1 I do Frame.BackStack.Clear(), press Back and the app just minimizes.. How to kill it with Back button?
You can add, in your main page definition:
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
Then
private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
if (!e.Handled && Frame.CurrentSourcePageType.FullName == "YourApp.MainPage")
Application.Current.Exit();
}
Warning: As others said, you should not use this and let the system handle the app closure. For example, if you use the Application Insights, I found that they are not sent to Azure when in Release mode
I think the above has been depreceated. Exit is now an event.
Try
Application.Current.Terminate();
you can simply create a button by using XAML and then add this code into your Main page xaml.cs
Application.Current.Exit();
MSDN recommends to not close apps in Windows 8.1:
We recommend that apps not close themselves programmatically unless
absolutely necessary. For example, if an app detects a memory leak, it
can close itself to ensure the security of the user's personal data.
When you close an app programmatically, the system treats this as an
app crash.
https://msdn.microsoft.com/en-us/library/windows/apps/hh464925.aspx#close
For security reasons, I need to log out the users when they exit the app and show login screen when they return back.
In Windows Phone 8 and Windows Phone 8.1 Silverlight there are Application_Deactivated and Application_Closing methods on the App class (or methods OnClose, OnDeactivate to override in Caliburn.Micro).
The only interesting events seems to be Suspend and Resume, but they do not called when I exit the app using the Start button and get back using the Back button or launching the app from the list.
What are the alternatives for Windows Phone 8.1 XAML?
(Setting ActivationPolicy="Replace" would solve half of the problem but I guess this is not possible, when WMAppManifest.xml is not event a part of a Windows Phone 8.1 XAML project).
The Suspending event will be called just after you navigate away from the app, but not in debug mode. I've build a simple app modyfing LocalSettings upon Suspending event and then acquiring information when Resuming.
You are probably aware, but for the sake of completeness of the answer - some remarks:
before Suspending event, the OnNavigatedFrom event is being called, but when you Resume, the OnNavigatedTo is not called - reference:
Note On Windows Phone, OnNavigatedFrom() is called when the app is suspended. OnNavigatedTo() is not called when the app is resumed.
to test Suspending/Resuming with debugger, use Lifecycle events in Debug location tab - more info
reference to Application lifecycle in Windows Runtime apps
I have a .NET application (C#, WinForms) application running on Windows XP. If i minimize my application, and have several other windows minimized to the taskbar, and click on my application (in the taskbar) then often i see the taskbar "icon" blink but my application fails to "restore" its window. Any suggestions to what might cause this? Any hints on how to check if my application is not getting an event from the mouse-click.
UPDATE: Could anybody give an example of, how to output any incoming events to an application. Something that allows me to e.g. print the received events using Console.Writeline() to see, if my application gets an event when I click on the taskbar?
http://www.catch22.net/software/winspy-17
I venture to guess that your app will become in focus.
AFAIK this should not have anything to do with your application. Is there any other application running which always remains on top?
You dont handle maximising and minimising to and from the taskbar in your app. That is to say you dont have to. Windows deals with this and so this would appear to be in no way related to your app not handling an event, rather Windows doing something (or not doing something).