14 September, 2010

WP7: How to make a phone call from your own application

How difficult can it be? Well – in the coming WP7 platform; making a phonecall from your own application is so easy that you won’t believe it!

image image image

WP7 introduces a new concept called Launchers. A Launcher is an object that basically tombstones your application and instead launches/activates a system functionality (in this case the Phone service). The code that does the above is here (is is darn easy!):

void btnLaunchPhone_Click(object sender, RoutedEventArgs e)
var pt = new PhoneCallTask();
pt.DisplayName = "Claus Konrad";
pt.PhoneNumber = "+45111111";


Technorati Tags:


ARojas said...

Hi Claus, according to this blog you i can make a call with this lines of code, its so easy, i have a another question. How can y finish a call from my app? or how i know the time of my call? i wish track the way of working. Thanks a lot.

Claus Konrad said...

The WP7 platforms relies a great deal on user interaction and acceptance. You can not (prematurely) end a call the user is currently engaged in. All Launchers will ask for permission by the user before executing.
You can launch the phonecall, but it is still the user who ultimately decides whether he wants to carry this out.
About duration: you can only log the timestamp of the launcher being activated.
When you start a call, you (the application) is put to sleep, meaning you are no longer running. Due to this reason, you are not able do anything as you are no longer running. Once the call is ended - you are resumed and running again. If you wish to know the duration it will be something like (now - time of sleep).

Anonymous said...
This comment has been removed by a blog administrator.

iPhone/XCode - not all cases are equal!

This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...