Do anyone know, how to subscribe on Activated event in a Windows Phone 8.1 Universal App?
In Windows Phone 8, I have used:
PhoneApplicationService.Current.Activated +=
WP8.1 Runtime has little different lifecycle - see MSDN. Depending on your needs you can use:
App.Current.Resuming event is called when you resume your app after it had been suspended by the OS - very often, typically few seconds after you navigate away, see also How to Resume an app,
Windows.Current.Activated is called when Window is activated/deactivated - you will have to check event's args. This event doesn't mean that your app had been suspended. You should also look out because this event will be fired for example when you show a dialog (when your window loses focus).
override methods from Application class - after using file pickers, sharing a target and more.
In windows phone 8.1 universal app use following code to subscribe for activated event.
Window.Current.Activated += Current_Activated;
Hope this helps!
Related
I have problem with PhoneCallManager.ShowPhoneCallUI in my windows Phone 8.1 universal app. When I make this call the phone call UI appears for a moment and then entire app disappears.
It works fine in debugger. I do specify valid phone number.
I don't have much informations, but the problem should be of the suspension manager, while you are in debug mode the app never enter in suspension mode, instead when you run the app normally and you bring up the phone call UI the app enter in suspension and crash, the problem should be the fact that you pass an object to the view, only strings and serializable element are allowed to be passed from a view to another as parameter without having issue on the suspension manager.
I have 10 buttons with their name is from "btn1" -> "btn10". I created button6_Click event method like this. But now, I want to invoke the tap event on these button in the Initialize method of my page in my WP Apps. How can I do that, I found that Windows 8 app can do this but on the Windows Phone I can't find anything to perform this action.
When developing WP 8.1 Windows Runtime application, what’s the equivalent of the PhoneApplicationService.Activated and PhoneApplicationService.Deactivated events? It looks like PhoneApplicationService class is only available in Silverlight WP apps.
Application.Suspending event is not fired on Deactivated event (i.e. when I press Windows button).
You are right, under WinRT there is no Activated/Deactivated events. Your App can be Activated, but it's little different than in Silverlight. About the lifcycle you can read here at MSDN.
Your App will be Suspended just after you Navigate away from it. But - it's not working while you are debugging - more information here. When you run normally your App it will be suspended very fast after you hit Back/Start buttons.
About Navigation there is one thing you should be aware - when you Navigate away from the App, first OnNavigatedFrom is fired, then Suspended events (in the way you have subscribed them). But when you go back to your App - then Resuming events are fired, but OnNavigatedTo is not fired - reference:
Note On Windows Phone, OnNavigatedFrom() is called when the app is suspended. OnNavigatedTo() is not called when the app is resumed.
In some situations your App can be put into Not Running state. More again at Lifecycle at MSDN.
I recently submitted a very simple app to the WP app store that is basically buttons that play sounds on click.
However, the app failed certification for the following reason(s):
Comments: Result: Fail
The application terminates unexpectedly in response to user input.
Steps to Reproduce:
Play music from music+videos hub and Launch the application.
Tap on any option from MY APPS NAME HERE.
Notice the application unexpectedly terminates.
Comments: Result: Fail
The application terminates unexpectedly in response to user input.
Steps to reproduce:
Play music on the device from the Music + Videos Hub.
Launch the application.
Press the device's universal volume control.
Select "Pause" from the device's universal volume control.
Notice the application unexpectedly terminates.*
My questions are:
What is "the device's universal volume control" ?
How can I stop these errors from happening?
I used Blend to assign a sound to the buttons so there is no code to work with as far as I can see.
I've written similar apps for the Android market and always use a 'stop' and 'release' for each mediaplayer element at the beginning of each button's code. I'm assuming I need something similar here but not sure how to go about it in WP8. Any ideas?
Unviersal volume control refers to the phone physical volume buttons.
Did you have AdMod ads in your app? Recently i found an app with the same behavior failing certification and it was caused by AdMob control doesn't working right when the volume buttons show the volume popup over the app.
If you follow this link, you can see a workaround:
https://groups.google.com/forum/#!topic/google-admob-ads-sdk/vw61ZdJALYo
Hope this helps.
My app is running on the foreground and the phone getting a incoming call. In the scenario, the phone is not raising any event to app like deactivated or closing. How do I identify my app not running ?
You app actually is still the current foreground app (so, kind of running, but audio/video is paused for obvious reasons).
You will get an Obscured event in the app, but you can't distinguish if this due to an incoming call, an incoming SMS, toast or reminder.
Here is a link to the MSDN documentation of the Obscured event you get. There is a corresponding Unobscured event you can also detect.