Quantcast
Channel: Anindita's Blog » Android
Viewing all articles
Browse latest Browse all 11

Building Cross – Platform Mobile Native Apps on Android,iOS, Windows Phone & Windows Store using Single Codebase,PCL with VS 2012/2010 & XAMARIN Tools

0
0

Cross Platform App development is always better choice for enterprises where we can avail support for Code Sharing, PCL (Portable Class Libraries) which can shared across multiple platforms of Mobility (aka Android, IOS, Windows Phone 8 / 7.x , Windows Store Apps).

Xamarin introduces such facility where a single code base can be shared across all enterprise mobile platforms along with the benefits of coding on .NET Framework 4.5 / 4.0 & Visual Studio 2012 / 2010.

Lets switch to check to build an Android native app on Visual Studio 2012 with C# for latest SDKs 4.2 using Xamarin tools for Android .

Download Xamarin for iOS, Android , Windows Phone & Windows 8 platforms from here

VS2012

Lets check the structure of theAndroid App on VS 2012. All layout files can be found under Resources folder. 

Android

  • Next, we are using a single code base file which contains the Business logic & App models that can be shared as a Link with iOS, Windows Phone & Windows Store apps.
  • Lets check the Android 4.2 app built on Visual Studio 2012 & .NET Framework 4.5 platform using Xamarin Tools.

AppIcon

Phoneword_Android

Call

PhonewordCall

  • Lets check, how to build the same app for Windows Phone 8 or 7.x platform using the same code base along with business logic.
  • Windows Phone 8 project contains the Main.xaml along with the common code base.

string translatedNumber;

private void Translate_Click(object sender, RoutedEventArgs e)
{
if(!String.IsNullOrEmpty(PhoneNumberText.Text))
{

// *** SHARED CODE
translatedNumber = Core.PhonewordTranslator.ToNumber(PhoneNumberText.Text);

CallButton.Content = “Call ” + translatedNumber;
CallButton.IsEnabled = true;
}
else
{
CallButton.Content = “Call”;
CallButton.IsEnabled = false;
}
}

private void Call_Click (object sender, RoutedEventArgs e)
{
var call = new PhoneCallTask();
call.PhoneNumber = translatedNumber;
call.DisplayName = PhoneNumberText.Text;
call.Show();
}

AppPreview_WP8

WP8

Call_WP8CallAction_WP8CaptureWP8

  • The Windows Phone App is compatible along with the Windows Phone 8 as well as 7.x versions.
  • For implementing on Windows Store , without altering business logics & models only the views need to be shared.
  • Lets check the project structure of this app for Windows Store.

PhonewordWin8

PhonewordScreenWin8

  • Asynchronous programming is one of core features related to Windows store, windows phone app developments along with other .net app development. Using PCLs, code sharing approaches too we can take help of simple async methods.
  • Shared code for Windows Store App :

string translatedNumber;
public ObservableCollection<PhonewordTranslation> Translations;

private void Translate_Click(object sender, RoutedEventArgs e)
{
if (!String.IsNullOrEmpty(PhoneNumberText.Text))
{

// *** SHARED CODE
translatedNumber = Core.PhonewordTranslator.ToNumber(PhoneNumberText.Text);

CallText.Text = “Call ” + translatedNumber;
// Win8, add to history list
Translations.Add(new PhonewordTranslation() {Phoneword=PhoneNumberText.Text, Phonenumber=translatedNumber });
}
else
{
CallText.Text = “”;
}
}

private void ListItems_Click(object sender, ItemClickEventArgs e)
{
var ci = e.ClickedItem as PhonewordTranslation;
var dialog = new MessageDialog( String.Format (“{0} translates to {1}”, ci.Phoneword, ci.Phonenumber));
dialog.ShowAsync();
}

AppIcon

  • For IOS development too, the app uses the same shared code -base which targets to iPhone, iPAD & Universal Mac apps which can be built on C#, .NET 4.5 using Visual Studio editor by Xamarin tools for iOS.
  • You can download the entire app over here .


Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images