On 5th April, we conducted a Hands on Labs for Xamarin Android. Most of the attendees were from ASP.Net or WPF background. So, we decided to take a simple application of calculating Auto Fare in Bangalore.
We first did a WPF application that does the calculation. Later we discussed how to extract the business logic and use PCL [Portable Class Library] to host it. Later, we started an Android project and used PCL to demonstrate code reuse. Code built during the event is uploaded to XHackers GitHub a/c for reference.
Attendees were able to follow through the lab, and reproduced the results and won some cool goodies. Few people were able to publish the app to stores.
On 19th April, we will be conducting Hands on Labs for Xamarin iOS. Don’t miss this event, as we are giving away a book, couple of T Shirts and some goodies.
Way to go XHackers
Lets assume app needs an external database, either hosted on cloud or on premise.
Build 2 sets of REST APIs, one for Authentication and another for actual app logic talking to your database. Also host them on different server instances if possible. If attacker is trying to break the authentication server and creates DDOS attack, your app logic server is not compromised. Also make sure every REST call for the app logic is validated by a token generated after authentication
Your client side UI can be very simple. If it is web application, you can go with simple HTML, jQuery with extensive use of Templates, and client side validations. No server side code cris-crossing your HTML and jQuery calls to REST APIs for data. This also helps in packaging the same HTML, JS, CSS in phonegap apps for any targeted mobile platform.
Your client can also be a native Windows app, Web app, Windows Phone App, iOS app or Android App. All of them will just have UI related code and all of them talk to REST APIs for data. This makes the UI/UX designers to actually work without worrying too much about server side coding.
If you architecture is based on Microsoft .Net platform, you can use Portable Class Library [PCL] to encompass your REST calls to easily usable function calls. And your Windows app, Web app, Windows Phone App, iOS using Xamarin and Android using Xamarin can all call the same PCL library for data access.
Do let me know if there are better alternatives.
Hope it helps
In most of the Windows / ASP.Net applications, if we have to send a parameter from master page to detail page, we have several ways of doing it, like Query string, POST parameters, session state, database, static class with static variable etc. In Xamarin, we can still do database and static class approach. Most commonly used approach is using PutExtra
var detailActivity= new Intent (this, typeof(DetailActivity));
detailActivity.PutExtra ("MyData", "Data from MasterActivity");
On the receiving detail page you can access the Value as below
string text = Intent.GetStringExtra ("MyData") ?? "Data not available";
Hope that helps Watch out for more soon!
We are conducting first XHackers event in Kolkata on March 27th 2014. We will be introducing Xamarin, how to write simple Android apps using Xamarin. Seeing the response of this meetup, we will conduct level 100, 200, 300 sessions, hands on labs, hackathons in near future.
If you are in Kolkata, don’t miss this event.
On the first day of World’s First Windows Azure Conference, 20th March, I presented a webcast on ‘Enrich your Windows 8 apps: Sensors and Media’
Essence of the talk was how to use Media like webcam and mic for capturing photos, audio and video and playing them back, Playing DRM enabled PlayReady content. Also quick demo of using sensors like Accelerometer, Compass, Gyrometer, LightSensor, Inclinometer and GPS. Also a concept called Sensor Fusion which showcases how using more than one sensor to build some cool new apps.
Most of the Windows RT enabled devices cannot run Visual Studio and if we have to test the sensors of them, Microsoft has released a set of Remote Debugging tools. You can find them at here and how to setup and debug here.
You can find the presentation at here .
All the code samples used in the demo are available at here
Continuing the series, lets understand how controls are created and used
Sounds pretty lame if you see from Windows developer’s view. But it is true decoupling of UI and Code behind. Makes sense?
Hope that helps you get started further Watch out for more soon.
For someone who starts with Xamarin without Android knowledge, it will be a tough nut to crack. Being a .Net developer for more than 13 years, I was wondering why someone would build an Android app the way it is built. But then there are some good reasons for why it is built that way. If you are a Windows Forms/WPF/ASP.Net developer, you might find this post easy to understand the differences.
For starters, lets look at Designer and Code behind files that we know very well
- UI designer files like .xaml for WPF, .aspx for ASP.Net , .cshtml for MVC windows form designer files are equivalent to .axml files which are usually found in /Resources/Layout/ folder. Sometimes .xml files are also used to define the UI. Xamarin provides a UI designer for .axml and .xml files
- Code behind files like .xaml.cs WPF, .aspx.cs for ASP.Net, controller for MVC, windows form code behind files are equivalent to activity.cs files that are usually inherit from Android.App.Activity class. Unlike the Designer and code behind are usually linked and easily identifiable in Microsoft world, Activity in Android usually links the Layouts by setting them manually in code using SetContentView like
Hope that helps you get started Watch out for more soon.
XHackers is a Gloal group of Xamarin Enthusiasts who want to share their love for Xamarin to all those who want to learn how to put Xamarin to best use.
We had our first meetup on Feb 1st 2014, group of 7 guys and 1 lady to form XHackers. We were so excited to talk about Xamarin, we forgot to take a picture :D. On March 1st 2014, we did an another meetup for introducing iOS and Android programming to bunch of enthusiasts. Started with programs on how to write ‘Hello World’ for each platform. It was a decent turn out for first public meeting. Post this event we have pushed hard to grow this community and we have crossed 100 members as of today.
Very soon, we want to conduct hands on sessions, weekend hackathons, iOS and Android App porting hackathons. Watch out for more at our Meetup page.
Now is the time for you to speak up and say what you want to hear from us. We want to hear your stories of your Xamarin Experience at our next meetup. Also let us know, how we should do our next meetup? Hands on classes? More hello world sessions? do send a mail to reachus at xhackers dot co
Also XHackers was meant to be a global group. Currently our first two meetups happened in Bangalore, India. If you want us to come to your city, do send a mail to reachus at xhackers dot co. One of core members will be visting your city for first meetup and help that city chapter started in your city.
The boilerplate ASP.Net WebAPI code takes care of many things that one have to do manually. Sometimes, we need more to enable it be mobile consumable. Below are the things I found after searching the web while I was fixing up a sample application for mobile.
This is not enabled by default. So we get following error
An exception has occurred while using the formatter ‘JsonMediaTypeFormatter’ to generate sample for media type ‘text/json’. Exception message: One or more errors occurred.
To fix this, go to App_Start/WebAPIConfig.cs and add the following lines in the beginning of Register function.
1: config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling =
3: config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling =
Cross-origin resource sharing (CORS)
Couple of links will help in this regard
Simplest configuration could be to install Microsoft.AspNet.WebApi.Cors NuGet package.
Hope it helps