Introduction:

We all knew xamarin and visual studio is great technology. You are no longer restrict develop only phone and tablet now you can develop Android wearable apps using xamarin. Android wear was officially released by google on 2014.

In this article, I will show how to setup and create Android Wearable App using xamarin ,



System Requirements

Mac / Windows 7++ Machine with 8 GB RAM.

Xamarin Studio 5.0 or new version/ Visual Studio 2012 or new version.

Visual Studio required professional or higher version because the Xamarin extension for Visual Studio will only be supported for non-express editions. Download Visual studio from here( https://www.xamarin.com/visual-studio)

Install Android SDK & Tools:

You can start open visual studio in Windows machine. Open Visual Studio (Run => type “Devenev.exe”)



You can verify all required SDK was installed in Visual Studio. If you do not have the latest SDK and tools installed, download the required SDK tools and the API. Go to Tools menu =>Android =>Android SDK manager. Android SDK manager window will visible in your system like below


Create Android Wear emulator

In order for us to run the android wear application we need to first setup an emulator. You can create one by following these few steps. Go to Tools in Visual Studio > Andriod > Andriod Emulator Manager. See below



Following screen, you will get know already created emulator. if you want to create new emulator click on “Create “button



After click on create button and provide following information AVD name, Device Name, chose correct Target platform and click on Create.



If you get any error "No CPU /ABI system image available for this target” means target SDK not installed. you can chose different target or install specific target SDK. when creating the device, make sure that the correct target of the OS is selected, but especially that the CPU is Android Wear ARM. after creating emulator you will receive following message for confirmation



After click on Okay you will get following screen for list of emulator


Create New Project:

You can follow below steps for Create your first Android Wear app and run it on a Wear emulator . File => New => Project. you can select project as Android and select template is Wear App. Now automatically project and wear reference will added .



See below screen for project structure and reference



In the Solution ,included xamarin android wearable reference and icon for tile image ,3 layout for rectangle and round watch and phone layout with common MainActivity class

Round / Rectangle Main.xaml:

I have included sample reference axaml code .you can modify as per your requirement

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:deviceIds="wear_round">
<Button
android:id="@+id/msdnbutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/msdn" />
<Button
android:id="@+id/csharpbutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/csharp" />
<Button
android:id="@+id/bloggerbutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/blogger" />
</LinearLayout>

MainActivity.CS

In MainActivity Class, create onbutton click and show the notification

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Support.Wearable.Views;
using Android.Support.V4.App;
using Android.Support.V4.View;
using Java.Interop;
using Android.Views.Animations;

namespace DevEnvWear
{
[Activity(Label = "DevEnvWear", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;

protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
var v = FindViewById<WatchViewStub>(Resource.Id.watch_view_stub);
v.LayoutInflated += delegate
{
// Get our button from the layout resource,
// and attach an event to it
Button buttonmsdn = FindViewById<Button>(Resource.Id.msdnbutton);
Button buttoncsharp = FindViewById<Button>(Resource.Id.csharpbutton);
Button buttonblog = FindViewById<Button>(Resource.Id.bloggerbutton);
buttonmsdn.Click += delegate
{
var notification = new NotificationCompat.Builder(this)
.SetContentTitle("MSDN")
.SetContentText("https://social.msdn.microsoft.com/profile/j%20suthahar/")
.SetSmallIcon(Android.Resource.Drawable.StatNotifyVoicemail)
.SetGroup("group_key_demo").Build();
var manager = NotificationManagerCompat.From(this);
manager.Notify(1, notification);
};
buttoncsharp.Click += delegate
{
var notification = new NotificationCompat.Builder(this)
.SetContentTitle("C# Corner")
.SetContentText("http://www.c-sharpcorner.com/members/suthahar-j")
.SetSmallIcon(Android.Resource.Drawable.StatNotifyVoicemail)
.SetGroup("group_key_demo").Build();
var manager = NotificationManagerCompat.From(this);
manager.Notify(1, notification);
};
buttonblog.Click += delegate
{
var notification = new NotificationCompat.Builder(this)
.SetContentTitle("My Blog")
.SetContentText("www.devenvexe.com")
.SetSmallIcon(Android.Resource.Drawable.StatNotifyVoicemail)
.SetGroup("group_key_demo").Build();
var manager = NotificationManagerCompat.From(this);
manager.Notify(1, notification);
};
};
}
}
}

Output Screen:

You can refer below screen for output. Click on tile => click on any button => swipe to home and see the notification




Microsoft Azure Active Directory (Azure AD) to add authentication and authorization to Our web, mobile Application and web APIs. In this article I shown below how to create / implement Azure Active Directory authentication login using xamarin.Forms . I have seen many article for the process of moving the management experience for all Azure services from the ‘classic’ portal at https://manage.windowsazure.com ,Here I am showing new portal at https://portal.azure.com for Azure AD Application creation and User creation .Azure Subscription Login
The New Azure Portal is that you don’t need an azure subscription to use it. You and other administrators in your organization can manage your tenant in the new portal without any of you needing to get and manage to an azure subscription. You can directly sign -in as usual with your work or school account

Azure Active Directory Application creation:

I will show below steps for application creation, user creation and permission configuration. While implement mobile application, we need Client ID, tenant, return url so here, I will show how to get all configuration information from following steps.

Step 1: App Registration:

Login to Microsoft Azure Portal https://portal.azure.com and choose Azure Active Directory from the sidebar.



The under Manage Select on App Registration => Click on + Add button

Provide the following details, name for the Application, select the Application Type as Native(Mobile application) or Web app/API, and for Sign-on URL enter your application URL and Click on Create


Step 2: App Required Permissions:

We need to give permission to access application from mobile or web so follow below steps for grand permission. Select on newly created application => Select on Required Permission => Click on Grand permission.


Step 3: Create new user:

Create user for access the application. choose Azure Active Directory from the sidebar => Select Users and groups =>Select All Users=> Click on +Add =>provide the user details as below Name of user, user name (email id).


Step 4: Get Client ID and Redirect Url:

The Client Id is unique identifier for our application. We need client id for implement Azure AD authentication in mobile application so you can follow below steps for get client id. choose Azure Active Directory from the sidebar =>Select App registrations =>Select newly created application => Click on property = > Use Application Id as client ID

Click on Redirect Url under settings =>get redirect url / update redirect url



Step 5: Get Tenant:

We already register our application in a Azure AD tenant. We need tenant ID for implement AD authentication in mobile application. you can follow below steps get tenant id.

choose Azure Active Directory from the sidebar => Select on Properties => use Directory ID as tenant ID



You can implement Active directory login in Web ,Mobile ,Windows application using Client ID ,Redirect Url and Tenant ID ..

Issue :

While trying adding Nuget package for Azure Active Directory ('Microsoft.IdentityModel.Clients.ActiveDirectory 3.13.8') , it is possible you will receive an error complaining that the package does not contain any assembly references which are compatible with the targets of your PCL project. The error will be something like below.

Severity
Description
Error
Could not install package 'Microsoft.IdentityModel.Clients.ActiveDirectory 3.13.8'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Solution:

ADAL does not support windows phone 8.1 version so we need to follow below steps for resolve above shown issue

Remove Installed all Nuget package
Removing the windows Phone 8.1 project from solution
Remove target platform from the PCL project
Step 1: Remove Installed all Nuget package
Go To solution > Right Click > Manage Nuget Packages > Click on Installed tab > uninstall all installed package like (Including Xamarin.Form etc ) .
If you are not uninstall the package and trying to change the targeted platforms by removing the target Windows Phone 8.1 you would get an error.



Step 2: Remove the Windows 8.1 project from Solution

ADAL does not support Windows Phone 8.1 so you need remove windows 8.1 project from solution . Only removing the Windows Phone 8.1. project from your solution will not resolve this issue. You still need follow next steps as well

Step 3: Remove target platform from the PCL project

Right click on your PCL project > Click on “Properties” > Go to the tab “Library” > You can see list of targeted platforms > Press the button “Change” > uncheck the target “Windows Phone 8.1” and “ Windows Phone Silvelight 8” > Press the “OK” button

Wait a few seconds and the dialog will be gone and the target is removed from the PCL project.



Now you can able to install ADAL nuget package from your solution



Azure Mobile App Service is easy to rapidly build engaging cross-platform and native apps for iOS, Android, Windows. We can use implement following mobile feature using Azure and create backend logic in C# or Node.Js

Store data in Azure Cloud Storage

Store image using blob storage

Azure AD Authentication

Send Push notification

Access on-premises resource

This article will be an step by step guide on how to create mobile apps service using azure.


Prerequisites

If you are not having Azure account, you can click here for a free trial azure subscription.

If you want to get start with azure app service before signup to azure account. Try App Service


Create Mobile App Service

Step 1:

Sign -in into Azure portal

Step 2:

In the upper left corner of the azure portal. Click on + New and type Mobile Apps in search box like below

Step 3:

Select Mobile Apps and Click on Create


Step 4: Create Mobile App

Provide the App name, Resource Group name and click on create.


Step 5: Successfully created Mobile App Service:

After Click on Create. Wait a few minutes for the service to be deployed successfully before proceeding.


Step 6: Mobile Service Settings

Click on Menu > Select App Services > Select newly created App Service(DevEnvDemo) > Click on (…) > Select Settings


Step 7: Select Client Application platform:

Search “Quick Start” > Select client application platform (Xamarin,Windows,native App) > Select Database ( Click on Connect a database)


Step 8: Create Data Connection:

Click on + Add button


Step 9: Select or Create Database:

Select database connection type as Sql Database > Select Sql Database configure Setting > Create New Database or Select database > if New Database – provide new Database name > Select Server or create New Server > if new server – provide server details and click on Select > Click on Ok


Step 10: Data Connection Status

After Click on Ok. Wait a few minutes for the Data connection create successfully before proceeding or click Notification icon and check data connection is created or not


Step 11: Download Client Application and Mobile Service:

Select client application > select backend language (C# or node.js ) > Click on Download button for both client and cloud project

now you can download cloud and Client application

Step 11: Publish and Debug Server Project

Download install language specific SDK https://azure.microsoft.com/en-us/downloads/

Open Visual Studio as Run as Admin, rebuild the project to restore NuGet packages.

In Solution Explorer, right-click the project, click Publish.

Click on Microsoft Azure App Service > Next > sign-in with your Azure credentials.


Select App service:



Provide server details > click on validate connection and publish the service



Wait few minutes for deploy service


Step 12: Run and Debug Application

Now you can Extract the client project that you downloaded, and then open it in Xamarin Studio or Visual Studio.



I believe this article will help you to create mobile app service in Azure. If you have any question or feedback, please share in the comment box.

Playing with keyboard shortcuts is very interesting and reduce the head-ache of using mouse again and again while programming with visual studio IDE. Actually, keyboard shortcuts also enhance your productivity and make your programming life easy and convenient. So, Here i am share a list of visual studio keyboard with different platform

Visual Studio For Windows :

Here you can find about Visual studio shortcuts for windows



Reference from : https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf

VisualStudio For Mac :

Here you can find about Visualstudio shortcuts for Mac



Reference from : https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf

VisualStudio For Linux :

Here you can find about Visualstudio shortcuts for Linux



Reference from : https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf

Issue:

In Xamarin Form , While adding reference Sqlit PCL or PCl storage ,etc . if you get following error

Severity Code Description Project File Line Suppression State
Error Unable to resolve dependencies. 'Xamarin.Android.Support.v4 23.0.1.3' is not compatible with 'Xamarin.Android.Support.Design 23.0.1.3 constraint: Xamarin.Android.Support.v4 (>= 23.0.1.3)', 'Xamarin.Forms 2.2.0.45 constraint: Xamarin.Android.Support.v4 (= 23.3.0)'. 0.

Just follow below steps for resolution

Step 1:

Close Visual Studio

Step 1:

Navigate following Folder C:\Users\<username>\AppData\Local\Xamarin
and Remove “ Zib “ Folder (it will re-create automatically while build solution )

Step 2:

Right Click on Your Solution /Project ➔ manage nuget Package➔ Click Update ➔ Update Xamarin Form like below


Step 3:

Restart Visual studio⇒Open project ==> Clean Solution and build

Step 4:

Add your Nuget package Now .



After upgrade xamarin Form , if you get below issue
Issue :

obj\Release\android\src\mono\android\support\v7\internal\widget\ActivityChooserModel_OnChooseActivityListenerImplementor.java:8: error: package android.support.v7.internal.widget.ActivityChooserModel does not exist

android.support.v7.internal.widget.ActivityChooserModel.OnChooseActivityListener
^
obj\Release\android\src\mono\android\support\v7\internal\widget\ActivityChooserModel_OnChooseActivityListenerImplementor.java:28: error: package android.support.v7.internal.widget does not exist

public boolean onChooseActivity (android.support.v7.internal.widget.ActivityChooserModel p0, android.content.Intent p1)
^
obj\Release\android\src\mono\android\support\v7\internal\widget\ActivityChooserModel_OnChooseActivityListenerImplementor.java:33: error: package android.support.v7.internal.widget does not exist

private native boolean n_onChooseActivity (android.support.v7.internal.widget.ActivityChooserModel p0, android.content.Intent p1);
^
obj\Release\android\src\mono\android\support\v7\internal\widget\FitWindowsViewGroup_OnFitSystemWindowsListenerImplementor.java:8: error: package android.support.v7.internal.widget.FitWindowsViewGroup does not exist

android.support.v7.internal.widget.FitWindowsViewGroup.OnFitSystemWindowsListener
^
obj\Release\android\src\mono\android\support\v7\internal\widget\ViewStubCompat_OnInflateListenerImplementor.java:8: error: package android.support.v7.internal.widget.ViewStubCompat does not exist

android.support.v7.internal.widget.ViewStubCompat.OnInflateListener
^
obj\Release\android\src\mono\android\support\v7\internal\widget\ViewStubCompat_OnInflateListenerImplementor.java:28: error: package android.support.v7.internal.widget does not exist

public void onInflate (android.support.v7.internal.widget.ViewStubCompat p0, android.view.View p1)

obj\Release\android\src\mono\android\support\v7\internal\widget\ViewStubCompat_OnInflateListenerImplementor.java:33: error: package android.support.v7.internal.widget does not exist

Resolution :

Step 1:

go to following folder

C:\Users\<username>\AppData\Local\Xamarin

Step 2:

clear all the folder and files.

Step 3:

Rebuild solution

Xamarin is great technology for develop cross mobile application development. You can create, Build and Debug iOS application in windows machine using Visual Studio. In this article, I will explain what are the way to debug and build Xamarin.iOS application in windows machine. 

Xamarin and Microsoft giving very great solution for create, build and debug IOS application on windows machine using visual studio. but, it cannot do this alone, an IOS app cannot be created without apple Compiler, and it cannot be deployed without apple certificate and code-signing tools. Read below I will explain about software requirement and steps. 

Software Requirement

You can install following software from Windows and Mac machine.
Build and Debug Xamarin.iOS Application on Windows Machine

Windows Machine

It greatly helps if your machines are physically near each other, since when you build and run on Windows, the iOS Simulator will load on your Mac. 

Build and Debug iOS Application

I have explained about basic xamarin.Form application creation in my previous article .You can refer and create basic xamarin.iOS or xamarin.Form application
After create, Visual Studio will prompt you to prepare your Mac to be the Xamarin build host using below 3 steps. 

Mac Machine

Step 1: On the mac Machine, Select “System Preferences” 

Build and Debug Xamarin.iOS Application on Windows Machine


Step 2: In System Preferences, Click on “Sharing” 

Build and Debug Xamarin.iOS Application on Windows Machine 

Step 3: In Sharing, Turn on Remote Login and Change Allow access to All Users or Only these users and add a user. 

Build and Debug Xamarin.iOS Application on Windows Machine

Windows Machine

Step 1: In the Visual Studio, you can click on “Connection Indicator “


Build and Debug Xamarin.iOS Application on Windows Machine


Step 2: You Can Select your mac name from mac agent window and click on “connect”. 

Build and Debug Xamarin.iOS Application on Windows Machine 

Step 3: you can enter mac username and password and Click on Login .


Build and Debug Xamarin.iOS Application on Windows Machine 

After connection, Connection indicator color will change to green, If its connection is very less bandwidth means it will change to orange color (it’s not recommended for debug application) 

Build and Debug Xamarin.iOS Application on Windows Machine 

Your app will compile and execute, but you won’t see it running on Windows. Instead, you’ll see it on your Mac build host. 


iOS Simulator Remoting

The Evolve 2016 Conference, Xamarin announced iOS Simulator remoting that will soon allow you to interact with apps running in Apple iOS simulator as through the Simulator were running on your Windows Machine.

iOS Simulator Remoting also you need follow above all the steps and below steps as well 

Windows Machine

Step 1: Download the installer and install on your Windows computer
Step 2: After install, In Visual Studio go to Tools > Options > Xamarin > iOS Settings and tick the box for Remote Simulator to Windows:


Build and Debug Xamarin.iOS Application on Windows Machine


Output


Now build and run solution and ios simulator will open in windows machine 

Build and Debug Xamarin.iOS Application on Windows Machine


Issues and Resolution


Issue 1: 


Error Cannot resolve reference: C:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/Xamarin.iOS/v1.0/Facades/System.IO.FileSystem.Watcher.dll I1Vector.iOS

Resolution:

This issue happened because of different versions of Xamarin.iOS on Windows Machine and mac machine. After updating xamarin.ios, this problem will get resolved.
How to Check xamarin.iOS Version Number ?
In Windows Machine, Go to Visual Studio ➔ Help ➔ About Microsoft Visual Studio

In mac machine, Go to Xamarin Studio ➔ Select Xamarin Studio Menu ➔ Click About Xamarin Studio ➔ click Show details





How to Update Xamarin.Ios in Mac and Windows?

Mac Machine:

Go to xamarin Studio and Click on “Check for Update” and Update

Windows Machine:

Go to Visual Studio ➔ Tools ➔ extensions and updates.
Some time it won’t available in update list. if it’s not available, go to control Panel➔Uninstall program ➔ Select Visual studio ➔ and Click Change option and update
Issue 2: Mac Agent can't connect after update:
Starting connection to mac machine. Xcode license must be accepted in order to be connected and working against the Mac
 


Solution: 


Go to Xcode ➔ Preferences ➔ Location
Check if "Command Line Tool" set or Select XCode version
Run sudo xcodebuild -license in terminal
Xcode license must be accepted press Space bar and press q
Issue 3: iOS simulator not display on Windows 

Solution 1: Check Windows and Mac firewall rule or disable and test application. 


Solution 2: 


You need make sure xcode installed in Application Folder. If it’s not ,you need to change in visual studio Apple SDK path


Build and Debug Xamarin.iOS Application on Windows Machine





Featured Post

How to Get an Free Azure Subscription for Learning

This guide will help you get started with Microsoft Azure for free. It explains three easy ways: using a Free Azure Account Signing up for A...

MSDEVBUILD - English Channel

MSDEVBUILD - Tamil Channel

Popular Posts