In continuation to blog posts in this series on plugins, today we’ll cover a plugin to make phone calls.
As we understood before, all platforms support phone calling (just like emailing, texting, etc…) and Xamarin makes it easier with one common language – C#. However, developers still need to learn
In case of Windows Phone, one can initiate a phone call by using following code. In this case, Windows Phone has special class which allow developers to perform this task.
In case of Android, developers can use ‘Intent’ and ‘URI activation’ to start a new phone call.
In case of iOS, same concept of URI activation can be applied. As shown below in the code, developers can create a URI with telephone number and it will launch default application to make a phone call.
Now, in case of Xamarin.Forms developers can use same Messaging Plugin for Xamarin and Windows plugin to implement phone functionality across the platforms.
This way, developers can utilize the power of plugins to write one code which can work across different platforms, without bothering about underlying APIs.
Xamarin provides native, cross-platform mobile application development using language we all know and love – C#. However, it is still required to learn concepts of each platform. For example to send text message (SMS) in all these three platforms there are different set of APIs.
Below API is for Android, which uses SmsManager to send the text message. There is another way to do this using Intents.
In case of Windows Phone, ChatMessage allows us to declare and send text message. This API is available in WinRT platform. In case of SL based apps, we need to use Launchers/Choosers.
In case of iOS as shown below, there is no API as such. But we use URL to launch default messaging app. In this case, we cannot set the message body, which we want to send out.
Life will be much simpler if there will be just one API on all these platforms which will take care of sending text messages and as I developer we don’t need to bother about on which platform it is being called. Here comes components and plugins. My friend James has written a nice blog about ‘What Exactly is a Plugin for Xamarin?’. You can read it here
In our case, we’re going to use Messaging Plugin for Xamarin and Windows which allow us to use same API to send text messages. Below code is written once in a Xamarin.Forms project which depending on platform on which code is executing, send the message using that platform’s APIs.
Using this plugin, it becomes easier to send text messages on Android, iOS and Windows. And this is the magic of Plugins for Xamarin.
In future posts, we’ll cover some of the best plugins and components which can help you build cross-platform mobile applications with single code-base.
I hope you’ve enjoyed this.
Android is one of the mobile platforms with large user base. Every mobile developer wants to have their app on this platform. Xamarin provides great tools to build apps for Android devices using best set of tools (Xamarin.Android & Xamarin.Forms) and the language that everyone loves – C#. Having said that, it is super important to try these apps before publishing to the store, just to make sure those apps look great, work great on devices. No doubt, trying these apps on real device is highly recommended for precision and exact result. But not everyone can afford to buy all the Android devices to see how their apps works on real device. Here comes the Android emulator. Till now, Android emulators are notorious for their poor performance. People used to joke about Android emulator’s startup time that they could take a coffee breaks till it boots-up.
But these days are gone. At Evolve 2014, Xamarin has introduced a new product – Xamarin Android Player – one of the fastest and cool tool to use. It uses Intel VT-x, AMD-V technologies to make it faster. On top of it, OpenGL 2.0 helps it to deliver smooth user interface. Xamarin Android Player is available for both, Mac and Windows. You can download it from http://xamarin.com/android-player.
Once you install it, you can download available images and use them to try your app.
Now you can create a new Android app or use your existing app and deploy it right from the Visual Studio or Xamarin Studio drop-down menu.
The next image will show you more details about Android Player. Once the app is deployed on Android Player, there are tools which allows you to simulate various setting of the Android device. For example: battery, volume, screen rotation, location (GPS), etc.
Just to show, how it simulates, you can try a Xamarin Android Player mini-hack from Evolve 2014 mini-hacks. You can download all of them from here: https://github.com/xamarin/mini-hacks
The app display changes as you change the battery percentage.
Xamarin Android Player features:
1. Simulate, run, debug and demo apps
2. Hardware simulation: Battery, Location (GPS), Volume, Webcam (coming soon)
3. Take screenshots
4. Drag and drop APK for installation
You can read release notes for Xamarin Android Player here: http://developer.xamarin.com/releases/android/android-player/
I hope this will make your Android app development much more easier and fun.