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.

Insights - Add New App

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

Add Xamarin.Insights NuGet Package

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

Initialize Xamarin.Insights

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.

Catch  & Report Excpetions

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.

Insights - Exceptions Home

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.

Individual Exception Details

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

Individual Details

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.

Android Player - Main Screen

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.

Select Android Player from 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.

Details about Android Player

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.

Battery Simulation on Android Player

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

Events! Events!! Events Everywhere!!!

I’m drafting this blog post while attending (virtually) Apple Live event about iPhone 6 and Watch. And this is a start of series of events that are happening in near future. This is your one reference guide to those events. Don’t miss them if you’re a .NET Developer, Xamarin developer or a Microsoft MVP. Smile

PUG DevCon 2014

14271_10152748338121584_4822679446261989292_n

PUG DevCon is a premier event for developers in and around Pune, India. This is going to be a 2 days, multi-track event with industry experts and speakers like Daniel, Nauzad, Raj, Guruji (Sanjay Vyas) and many more. This event is happening on 13th and 14th Sept at MCCIA, SB Road Pune. For more information visit: http://aka.ms/devcon

Xamarin EVOLVE 2014

Capture

This almost a week long event is all about cross-platform mobile and smart gear app development using Xamarin. This event also includes hands-on training and sessions by various industry experts and it is happening at Atlanta, GA on 6th Oct till 10th Oct. For More information visit: https://evolve.xamarin.com/

TechEd 2014

Capture

Microsoft India’s premier technology event – TechEd is happening from 5th till 6th Nov and this time at Lalit Ashok, Bangalore. You can find more information about this event at: http://www.india.msteched.com/ 

MVP Summit

Capture

If you’re a Microsoft MVP, you might have received MVP Summit invite –  a special invite only event for MVPs. This time it is happening from 3rd Nov till 6th Nov at Redmond. Follow the invite for more information.

And much more:

Apart from these events, there are many events in December, for example friend Kunal and Deepak are getting married. Aviraj is coming for a short India visit and I think these are big events for us. And these are very special invite only events Smile

Till then, don’t forget to register and see you at all these events. ‘Say Hi’ if you’re around (except TechEd, I’ll be at Summit).

Namaste

Mayur Tendulkar

Xamarin.Forms for Windows Phone –Differences You Must Know

Xamarin.Forms is cross platform solution to create native apps. Whilst Xamarin allows us to build native apps for each platform (Android, iOS and Windows) with maximum code sharing, Xamarin.Forms goes one step ahead and allows UI code sharing as well. That means, I can create a TabbedPage and it will be rendered natively on each platform as ActionBar, UITabView and Pivot.

Xamarin.Forms allows creating UI in both C# as well as XAML. To keep things simple and less confusing across different platforms, there are new properties, new elements. XAML as a language is still the same. So we get to create objects from XAML, initialize them using InitializeComponent(). Everything is still the same. You just need to know the small differences. For example there is no Margin property, but there is Spacing property <grin>

While you can add a XAML page from XAML project template category, you should add one from Code -> Forms Xaml Page

image

The first thing to notice here is namespace

image

And this actually makes the difference. The two lines define the XAML page. First two are for Xamarin.Forms whereas last two are for normal XAML page in Windows app.

When creating User Interface, Xamarin.Forms provides Views (controls in our language) which abstract away the different controls in different platform. So, to create a TextBox on Windows Phone and a button which will be right aligned within StackPanel, following code will do the magic:

image

As you can see here, rather than StackPanel, StackLayout is used to represent controls positioned in stack (horizontal or vertical) and to avoid confusion with any stack in these platforms. This StackLayout will internally render native Stack of controls on each platform.

Also, in above code, Entry element is used, which is new to us. However, this entry represents a single line text-input control. That is, on Windows Phone it will become a TextBox.

Along with control names, some properties are named differently. For example Margin is now Spacing. We have left 25px space from each side in our code. Padding is still the same.  HorizontalAlignment is changed to HorizontalOptions. And possible values for that will be: Start [Left], Center and End [Right], with option to mention Expand which will take-up the space available. It also has FillAndExpand option, which is similar to Stretch mode.

While working with Font, usually we’ve different properties for FontFamily, FontSize, FontWeight etc. In Xamarin.Forms, we get one Font property which accepts multiple values (comma separated), which is parsed at runtime (Type Converters). So, below code can render TextBlock (label) with specified font details:

image

One thing to notice here is OnPlatform element. This element helps to override certain values (in above code, label renders with different font setting on different platform) for specific platform. There is a Device class with methods to work on platform specific code in XAML or C#.

The data binding concept is still the same as it was in traditional XAML.

image

The code above mentioned, with details is available at ‘An Introduction to Xamarin.Forms’ i.e.: http://bit.ly/1l1zg06 on Xamarin.com site.

Having said that XAML syntax is still the same. The features like code behind in partial class (with InitializeComponent), Type Converters, Property Element syntax, Attached Property syntax, Content properties, external library declarations (xmlns : somedifferentype=”uri”), adding event handlers, ResourceDictionary, StaticResources, etc… are still the same.

With this, I’m sure Xamarin.Forms will help C# and XAML developers to do Rapid Application Development on multiple platforms.

You can read more here at:

  1. An Introduction to Xamarin.Forms
  2. Getting Started with Xamarin.Forms: Basics
  3. Xamarin.Forms Samples
  4. XForms Labs (Open Source Project)

Happy Coding & Namaste
Mayur Tendulkar

Exploring NDepend

Recently, I was looking for tools to improve code readability as well as tools which can help me to write better code. There are many tools. And then I met NDepend – often called as ‘Swiss Army Knife for .NET developers’. And glad that I could try it out. This tool can check your code on many parameters, for example coding standards, code quality, dependencies and what not.

Here, let me give you a glimpse of what it can do. However, I’m covering just 1% of what it actually does and what I understood. There are many things, which I’ve yet to explore.

To start with, when I open my project in NDepend, it analyzes it and gives a detailed report. One part of it is basic details about app statistics. It is like a dashboard.

image

This report shows, number of lines commented, assemblies and its member count and other parameters.

This tool also shows violated rules and how they can be fixed

image

On clicking on those violations, you will be taken directly to that code where it can be fixed.

One of the best and most important thing about this tool, also the one that I liked is it shows dependency graph. This can help you if you want to improve the app architecture. Basically you need to know your app’s dependencies when you’re deploying/publishing it. Lesser the dependencies, better the product Smile

image

One more thing, which I think as the key feature of NDepend is Treemap Metric View. In this case rectangles represent method and the size depends on the number of lines. However, this view can give more details. Read more about it here

image

As I mentioned before, I haven’t got a chance to explore all the features of this tool. But this post can give you the idea about what it can do and how it can help you. As and when I’ll explore more features of it, I’ll write it down here. Meanwhile, do give it a try here: http://www.ndepend.com/ 

Happy coding
Mayur Tendulkar