Attend: Microsoft Azure Conference 2015

Microsoft Azure Conference 2015

This time, Microsoft India is hosting its ‘Microsoft Azure Conference 2015’ in Pune. This is going to be a huge event for any cloud enthusiast with 2 days and more than 70 sessions. More details about this event is available here: http://www.microsoftazureconference.in/

In this event, I’m going to conduct a hands-on-lab on ‘Put Office 365 in Your Xamarin Mobile Apps’. In this lab, attendees will learn how to integrate Office 365 services in their mobile applications (Android, iOS and Windows)

As a homework, I’ll recommend to go through following links:

This will help you to understand the topic and be prepared for lab.

Namaste
Mayur Tendulkar

 

Advertisements

Plugin 04: FileIO

In continuation to blog posts in this series on plugins, today we’ll cover a plugin/library to perform FileIO.

There are different APIs on different platforms to perform FileIO. Having said that, Xamarin already makes life easier by implementing System.IO which is available in Android and iOS.

Following code can be used in Android to create a file and then read contents from it.FileIO - Android

Similarly, following code can be used in case of iOS application. FileIO - iOS

In case of Windows, using WinRT APIs, the case is little bit different as shown below:FileIO - Windows

Now to make life easier, there is a NuGet from Daniel Plaisted, which can help you to use same code on different platforms. You can find more information about the library from here: https://www.nuget.org/packages/PCLStorage/FileIO - Forms

This way, you can use one code (in C#) across all the three different platforms.

Hope you’re enjoying this series. Do let me know your feedback if you want to include any specific libraries/features.

Namaste
Mayur Tendulkar

Plugin 03: Phone Calling

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.

Screenshot 2015-02-23 10.53.12

In case of Android, developers can use ‘Intent’ and ‘URI activation’ to start a new phone call.

Screenshot 2015-02-23 10.56.09

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.

Screenshot 2015-02-23 11.13.09

Now, in case of Xamarin.Forms developers can use same Messaging Plugin for Xamarin and Windows plugin to implement phone functionality across the platforms.

Screenshot 2015-02-23 12.31.23

This way, developers can utilize the power of plugins to write one code which can work across different platforms, without bothering about underlying APIs.

Namaste
Mayur Tendulkar

Plugin 02: Email Messaging

In previous blog post we’ve seen how we can use plugins to send text messages and use same API across platforms without bothering about individual platform specific APIs. In this blog post we’ll continue to discuss plugins and see how we can send Email messages.

In case of Windows Phone, we can use EmailManager to send EmailMessage. The code will look like:

image.png

For Android, there is no class as such which can handle email messaging. Rather, we use something called as Intent.

image1.png

In case of iOS, we use built-in controller to pass parameters which can populate the email message and later-on send it.

image.png

Now, lets see how we can implement this feature in Xamarin.Forms using Plugins. The plugin which we used last time, is feature rich and also included capability to send emails. Refer Messaging Plugin for Xamarin and Windows in your applications and modify the code as shown below. Depending on the platform on which the code is executing, it will internally call the platform specific APIs.

image.png

Once again, using this plugin it becomes easy to send Email on Android, iOS and Windows Phone.

Namaste
Mayur Tendulkar

Don’t Re-Invent the Wheel: Use Components or Plugins In Your Apps

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.

image 

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.

image

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.

image

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.

image

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.

Namaste
Mayur Tendulkar

Revisiting Evolve – Insights

One of the factor for successful app is – continuous feedback from user. Even though, you anticipate all the possible bugs, once the app is on store, you’ll never know what can go wrong and when your app can crash on the user. You may want to know: how many users are using your app, when they are using, how they are using, what features they are using or if the app crashes, when, why and how it crashed. These analytics can help you to engage more with the audience and deliver great apps.
Thanks to Xamarin Insights, which was introduced in Evolve 2014. Using Insights, you can easily track down all these scenarios.
To get started visit https://insights.xamarin.com/ and create a new app.

Screenshot-2014-10-20-11.31.43

 

Insights is supported on Android, iOS and Windows/Phone apps. Using NuGet package, add Xamarin.Insights NuGet Package.

Screenshot-2014-10-20-11.35.20

 

Once you add this package, you need to initialise the Xamarin.Insights by using following code:

Screenshot-2014-10-20-11.40.34

Just remember, you need to initialise Insights before any exception can occur. For example, in case of iOS in Main, in case of Android in OnCreate of startup activity and in case of Windows in Launch event.
After this, whenever there will be any unhandled exception, it will be reported on the dashboard. To simulate this behaviour, lets add a button on screen and catch the exception and report it explicitly.

Screenshot-2014-10-20-11.42.39

As you can see, above code will raise IndexOutOfRangeException. Now, if you run the app in ‘release’ mode on ‘device’, it should show all these exceptions on Dashboard.

Screenshot-2014-10-20-12.17.12

Now, if you click on individual exception, you can see more details (incl. stack-trace) for that exception. This will also tell you more details about device on which app is running, the version of the device OS and other details.

Screenshot-2014-10-20-12.17.12

 

On this dashboard, you can go to Users tab and see individual user actions and how they received those exceptions.

Screenshot-2014-10-20-11.54.01

 

Insights give you APIs to report more details related to Users (individual user details like name, email id, etc…), their actions or traits (clicked on some button, navigated to some tabs, etc…) and also to add more details to exceptions. It can also send you email for individual issues. So, if there is any issue with high-priority, you’ll receive a notification mail and get notified about it. Insights, also allows you to integrate with HipChat, Jira, Visual Studio Online to get notified about issues.
Using Insights, you can easily engage more with your audience. If user is facing any issues, you can get notified about those issues. And once you solve those issues, you can contact user about updates. This will help your users to use your app more frequently while making it a successful app.
You can find more details about Insights at: https://insights.xamarin.com/docs or http://xamarin.com/insights
Hope to see more apps with Insights and user engagement.

Namaste
Mayur Tendulkar

Revisiting Evolve – Android Player

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.

Screenshot-2014-10-14-12.58.19

 

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.

Screenshot-2014-10-14-13.03.08

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.

Screenshot-2014-10-14-13.13.10

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.

Screenshot-2014-10-14-13.19.22

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.

Namaste
Mayur Tendulkar