How to detect calls while app is in the background? - windows-phone-8

So I understand that a foreground app can detect phone calls by registering for the obscured event, but while my app is running in the background, playing sound, sending notifications, etc, it does not hit the same event.
Is there a specific way to handle phone calls in this circumstance? The obscured event is the only one that I can find for detecting phone calls, but it won't work in this instance.

Unfortunately, with the current API there isn't...
In fact, I'd say that the obscured event can't even be considered a reliable way to detect an incoming phone call: you can use it right now for that purpose, but tomorrow Microsoft can just go ahead and add new stuff that will raise that very same event!

Related

Stopping background audio task on app termination

Due to the way that BackgroundAudio task and app lifecycle are built up, there doesn't seem to be a way to detect actual closing of the app and stopping its background task at this point.
This creates an odd situation for the user, where she can try to forcibly terminate the suspended-but-present app to "get rid" of the playing audio, yet the playback continues.
There is a possibility of reacting to the Suspending event, but that would just mean that the audio stops playing as soon as the user switches out of the app.
However, we are required to stop audio playback only when the user terminates the app via App Switch screen.
Is there any way of detecting that the app has been closed from its background task?
The BackgroundAudioTask is designed to continue even the main app has been terminated/suspended. There is no way to inform the BackgroundTask that the suspended app has been terminated.
After the app is suspended, no events are called or any code is run from your app. The last things what you can do is to put something into suspending event and/or window's events. You can save something in LocalSettings which will be inform the BackgroundTask that the app is inactive, it's also last chance to send a message to your task with information about UI status.
The above method is used in official MSDN sample.

Windows Phone 8 fire a background task on call picked without accessing any call details

I am looking to develop an application where i just need to detect whenever a call is picked up.
I do not need any details related to call log and just need the event to be fired which will manipulate the sensors and do some functionality.
Is it possible to have that kind of access. Is it available out of the box and if not, is there a way that I can request for access from Microsoft?
WP apps don't have this kind of access/functionality.
Only possible way would be to use the Obscured Event (http://msdn.microsoft.com/library/windows/apps/microsoft.phone.controls.phoneapplicationframe.obscured%28v=vs.105%29.aspx) Which requires your app to be launched all the time you want to capture the activity.
The problem here is that Obscured event is also fired in the case of alarm or lockscreen.
I doubt Microsoft will grant you access to more functionality.

Launch application automatically from a push notification on Windows Phone 8

I would like to launch an application using parameters provided from a push notification on Windows Phone 8.
The behaviour I wish to achieve is that as soon as the user receives the notification, the application will be launched with the parameters provided in the notification. I.e. seamlessly present the notification in a more user friendly way.
As far as I understood there are three push notification mechanisms. Toasts, Tiles and Raw.
None of them seems to be able to handle the wanted behaviour.
Toast: The message is shown even if the application hasn't been started. It does not start the application unless clicked on but seems to be closest to the target.
Tile: Message is shown if the application has been pinned. But they may be difficult to notice unless the tile is pinned fairly high on the start screen.
Raw: Works in more power states but requires the application to be running. This doesn't seem to be a match because I want the notification to be received when the application is not running. I couldn't find information about which application states where raw notifications are handled. I would prefer all.
Did I miss something in my research? If anyone has a hint of how to put an application in the foreground from a push notification (without user interaction) it would be greatly appreciated!
My first attempt was to trigger the application start using SMS but that seems to be a no go.
See my post Launch application automatically from an SMS on Windows Phone 8
You can not automatically launch an application on Windows Phone (and neither can you on iOS or Android). What you can do is provide a URI with the Push notification so the user is taken to a page with the needed information
you can not put an application in the foreground from background without user interaction.

ActionScript 3.0: Wait for response from Flash Player Settings window

I recently received some code from another developer and there's one piece I would like to rework. It's a flash app that works with mic and webcam. When it is started you are prompted to press a button - after that the usual flash player settings windows appears asking you to allow access to mic and cam. The application needs to wait for user's response on this question. It was achieved in the code I received in a rather awkward fashion. Application progressed on mouse movement event, which would not be registered since the flash player settings popup block the area. Once it out of the way - any mouse move would make application to go on. I need to rework with in some better way, because this piece of code is also used in AIR application that doesn't ask for allowance and, therefore, if you click the opening button you would need to move your mouse in order to get things running. I believe there must be some decent way to notify the app that settings popup is gone. Could anyone advice on this?
The correct way to do this in Flash Player is to listen for StatusEvent.STATUS event which is dispatched after the user either allows or denies you access to their mic. See the documentation for Microphone.getMicrophone().
In AIR, however, you don't have to ask for user's permission to access their mic and camera, so this event is not dispatched when your application gets access to the input device. In that case, you can check through Capabilities.playerType property if your code is running in AIR and then proceed with doing what you would have done in response to receiving permission to access user's input devices.

How does my app know if any incoming call coming to phone in Windows Phone 8?

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.