Thursday, November 1, 2018

Implementation of Font awesome


Introduction

Image result for font awesome


    Hello All Today we will understand how to add icon or images with help of font 
awesome.Font awesome is a font family which is to be add in project for get font awesome icons.
     Font awesome is a font family which is change the Combination of letters in way that are become icons.   

Steps

1.  Download the .otf Files.You can find both free and pro files here.

2.  Unzip these files and add these files in Projects in follow location:                       Droid: Demo.droid > Assets                                                                           iOS:Demo.iOS > Resources

3. Add All the .otf Files name which add in iOS project in info.plist.

<key>UIAppFonts</key>
<array>
<string>Font Awesome 5 Free-Regular-400.otf</string>
<string>Font Awesome 5 Free-Solid-900.otf</string>
<string>Font Awesome 5 Brands-Regular-400.otf</string>
</array>

4. Add these code in your Resource directory:

<OnPlatform 

x:Key="AwesomeFontFamily"

x:TypeArguments="x:String"

Android="Font Awesome 5 Free-Regular-400.otf#Font Awesome 5 Free Regular" 

iOS="FontAwesome5FreeRegular" />


<OnPlatform 
x:Key="AwesomeSolidFontFamily"
x:TypeArguments="x:String"
Android="Font Awesome 5 Free-Solid-900.otf#Font Awesome 5 Free Solid" 
iOS="FontAwesome5FreeSolid" />

<OnPlatform 
x:Key="AwesomeBrandsFontFamily"
x:TypeArguments="x:String"a
Android="Font Awesome 5 Brands-Regular-400.otf#Font Awesome 5 Brands Regular" 
iOS="FontAwesome5BrandsRegular" />



Mainly,There are different techniques to use font awesome family in Android and iOS.
In android,first write the otf file name then font family name and differentiate them from hash symbol(#), in other hand,in iOS,mainly we use just font name.

5.Now we ready to use font awesome.Here is a example of Font awesome:


<Label Text="&#xf031;FontFamily="{StaticResource AwesomeSolidFontFamily}" TextColor="Black"/>


In example,you can see that the text is in the specific format first we have to add "&#x" then the specific code for each icon(you can find these unicode on font awesome site) and then ";".  

Saturday, September 29, 2018

Create Platform specific popup in xamarin.iOS




    Hello Friends,In this blog we are understand how to arise popup on platform specific level in xamarin.iOS.
    When we use popup at platform specific level then we can customize popup as our requirement however in this post we show a how to arise a simple popup.
for show popup on iOS firstly we how to initiallize the Controller for popup UIAlertController then put Actions on this controller and at the end this controller is show on current ViewController 
    The Code is as follows:


 var Cantroller = UIAlertController.Create("Title Here", "Massege Here", UIAlertControllerStyle.Alert);
                Cantroller.AddAction(UIAlertAction.Create("Okey", UIAlertActionStyle.Default, null));
                var Window = UIApplication.SharedApplication.KeyWindow;
                var vc = Window.RootViewController;
                vc.PresentViewController(Cantroller, true, null);



Sunday, July 29, 2018

Pinch Feature in WebView in Xamarin.forms



Introduction: 

     Hello friends,In this blog we work on WebView control and create custom renderer in each platform specification for enhancement a pinch feature.

Programming:

Core:

       In forms project,we will create our MyWebView class and inherit it from Xamarin.forms.WebView class.this is the WebView class of Xamarin technology.now our MyWebView have all the features and properties of Xamarin.forms.WebView.
using System;
namespace Demo.Renderer
{
public class myWebView:Xamarin.Forms.WebView
{
}
}

Xamarin.droid:

      Here,we create a custom Renderer in droid solution and Export this renderer to our custom WebView.
using System;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Webkit;
using Android.Widget;
using Demo.Droid;
using Demo.Renderer;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(myWebView), typeof(Demo.Droid.myWebViewRenderer))]
namespace Demo.Droid
{

public class myWebViewRenderer: WebViewRenderer
{
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (Control != null)
{
Control.Settings.BuiltInZoomControls = true;
Control.Settings.DisplayZoomControls = true;
}
base.OnElementPropertyChanged(sender, e);
}
}
}

Xamarin.ios:

      Here We create custom Renderer for Xamarin.ios.this cutom renderer uses the native webview for adding pinch feature.

using System;
using Demo.Renderer;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(myWebView), typeof(Demo.iOS.myWebViewRenderer))]
namespace Demo.iOS
{
class myWebViewRenderer:WebViewRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (NativeView != null && e.NewElement != null)
{
var webView = ((UIWebView)NativeView);
webView.ScalesPageToFit = true;

}
}
}
}

Wednesday, July 4, 2018

Working of Geo locator in Xamarin

Intoduction

  Hi All, here we will discuss about the Geo locator in Xamarin technology based Mobile Applications.The Geo locator is much important for any mobile application which wants to access the location like any app which implement or if any app wants auto filled your address in any form etc. 

Steps for implement Geo locator :

1 Create a test Project :

   Firsty,We discuss on Cross platform Xamarin Project.so please choose cross Platform app when create a project on Visual Studio  2019.
     After this, we will get the initial view of project. if you have a already a working project then this step can be skip.  

2 Add nuget packages:

 In our project, There are three nuget packages which are sufficient for geolocation implementation,which are as follows:
      1.Download and install Xam.Plugin.Geolocator 4.5.0.6
            You can also install this package manually from here 
2. Download and install Plugin.Permissions 3.0.0.12
             You can also install this package manually from here
             3. Download and install Plugin.CurrentActivity 2.1.0.4
                 
                You can also install this package manually from here.this Plugin is only compatible for android solution.

 3 Work on permission in Droid:

     For accessing geolocation in Droid we have to give permission for two important permission which are as follows:
  1. ACCESS_COARSE_LOCATION
  2. ACCESS_FINE_LOCATION
These permission can be checked from 
Open-
       TestGps.Droid > properties > Android Manifest

Or Alternatively,Open TestGps.Droid > Properties > AndroidMenifest.xml 

and put folowing code:

<uses-android:name android.permission.access_fine_location="">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION">



 4 Work on Permission in iOS:

    In iOS, we can get the location services through adding some keys in info.plist
These Key and there string are as follows.

<key>NSLocationWhenInUseUsageDescription</key>

<string>This app needs access to location when open.</string>

<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>

<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location when in the background.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location when open and in the background.</string>

  we can add these code in info.plist through these steps
  1. Right click on info.plist in TestGps.iOS
  2. Choose iOS manifest editor and press OK.
  3. Paste the keys.
    

 5 Initialize the Plugin.CurrentActivity in Droid Solution:

  1. For initializing the Plugin.CurrentActivity,You have to put this code in mainActivity.cs. 
                       Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this,bundle);

 6 Find Location through Geolocator plugin:

 1. we have already create a demo view for show the longitude, latitude and other important information. 

  1. We have put these Code on button click event beacouse we want to run these code and get data on button clicked.

private async Task Button_ClickedAsync(object sender, EventArgs e)
{
            var locator = CrossGeolocator.Current;
            locator.DesiredAccuracy = 50;
            var position =await locator.GetPositionAsync();
            txt_Status.Text = position.Timestamp.ToString();
            txt_longitude.Text = position.Longitude.ToString();
           txt_latitude.Text = position.Latitude.ToString();
}


         Here,l ocator is object which gives us location through a asynchronous method GetPositionAsync(). the locator have by default 100 meter Desired Accuracy but it can be manually customize.

    3. Now,turn on your GPS and allow permission of location your app to access location feature from device. Now we get the location and the following screen we have get.


 Work on acquiring Permissions from User:


     if a user trying to gather information about location without acquire essential permission to their app, Which are given by user, the app is then crashed which we never want. so these steps help us for preventing crashing of app.

 1 Creating a interface:

    Now We have to create an interface.That's used for checking whether GPS is ON or OFF and if the GPS is ON then taking an step which help to ON GPS.

using System;
using System.Collections.Generic; using System.Text;
namespace Test_Gps.Interface
{
    public interface IGpsActions
    {
        bool isGpsEnable();
       void GpsOnAction();
   }
}


2 Implementing Interface:

   Now,we implement the interface in each platform that's are as follows:

In Droid:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.Locations;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using static Android.iedia.Audiofx.EnvironmentalReverb;

[assembly:Dependency(typeof(Test_Gps.Droid.GpsActionImplementation))]
namespace Test_Gps.Droid
{
    class GpsActionImplementation : Test_Gps.Interface.IGpsActions
    {
        LocationManager locationManager = (LocationManager)Android.App.Application.Context.GetSystemService(Context.LocationService);
        public void GpsOnAction()
        {
            Intent intent = new Intent((Android.Provider.Settings.ActionLocationSourceSettings));
            Forms.Context.StartActivity(intent);
        }

        public bool isGpsEnable()
        {
         
            return locationManager.IsProviderEnabled(LocationManager.GpsProvider);
        }
    }
}

In iOS:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreLocation;
using Foundation;
using UIKit;

namespace Test_Gps.iOS
{
    class GpsActionImplimantation : Test_Gps.Interface.IGpsActions
    {
        public void GpsOnAction()
        {
            UIApplication.SharedApplication.OpenUrl(Foundation.NSUrl.FromString(@"App-Prefs:root=Privancy"));
        }

        public bool isGpsEnable()
        {
           return CLLocationManager.LocationServicesEnabled;
        }
    }
}
These code are help us for finding if GPS is ON or whether OFF and we find the GPS OFF then send to the native page according to there platform specifications.

 3 work on gather permission at app level:

     Now,we work on gather permission at app specification level.It can be gather through cross platform nugat packages 
     For find Whether App level Permission is ON or OFF we use following code
            PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Location);

      This code give the permission that can be checked whether permission is accept or denied. 
PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Location);
status==PermissionStatus.Granted
Through the following we can go to the the app setting page where we can give the permission to our app.

crosspermissions.current.openappsettings()
            

       This Code is useful when we find that app does not have app level permission
        Now, the permission can be gather without reach to settings page,instead this approach we can also add code through this the app pop the popup and user can give permission on that popup. it can be possible through this code


var newStatus = await CrossPermissions.Current.RequestPermissionsAsync(permission);
Here new Status gives us information about the new state of permisson after the use select on popup.this code can be use anywhere you want to show that popup as onstart Activity.

Tuesday, June 19, 2018

Installment of Xamarin Technology in local system

Introduction

 Hello Friends,In this blog we talk about how to install Xamarin in our local system(like P.C.,Computer System etc.).Xamarin is as a technology of Microsoft which is very useful to create cross platform applications.Now,In further reading we understand how to install this technology and use step by step.

Steps For Install Xamarin:.

1 Install Visual Studio 2017:

 there are two type of visual studio which are use for Xamarin app development which are visual studio and visual studio for mac

  • Visual Studio is use for installing visual stdio in windows platforms whereas the Visual studio for mac is use for apple specific devices i.e. mac platforms.
  • Visual studio for mac is mainly targets the Android,IOS and Universal windows platform specific apps where the Visual Studio for mac is mainly targets the Android,IOS and MacOS specific apps.
  • Step are as follows:
  1. Go to visual studio official site i.e. from here.
     2. Download the visual stdio as your requirment in your system.

     3. Now you get the visual studio installer run that application in your system           then you get the window:
      4. Now you can choose packages as your requirements but today our requirement  is only install Xamarin so please check these packages:
  • Mobile development with .NET.
  • .NET destop development(For windows Development)
  • Universal Windows Platform development(For windows development)
       5. Now Install these package in your Visual Studio.

       6.Check the update in your Visual Studio framework and if they are exist then download them.you can check update as follows:
  •  For Visual studio for windows:go to Tools>Extensions and Updates....
  • For Visual Studio for mac: go to Visual Studio>Check for Updates...

  2 Install Xcode:

    This step is only for mac specific system and this step is must for iOS specific app development
  1. Go to official site for install Xcode i.e.from here  
  2. Now download the Latest version of Xcode from the site and install it in your macOS based system.

   3 Develop iOS based App in Visual Studio for Windows:

      Now,this is some logical step for genrate iOS based app in Visual Studio for Windows you can understand from these points:
  • Every Application, which is to be runnable in macOS based system(i.e. iOS phone,pad,laptops etc.) must be develop through Xcode which use swift language.
  • So,For develop iOS based app in Visual Studio for Windows, you can use mac agent
  • For mac agent,at least one macOS based system should be connect to your Windows based local system Network then you just Remote Login your System to macOS based system.
  • then you create create iOS based system in Visual studio for Windows.

    4 Download Android SDK:

       Android SDKs in very important for building an android OS based application.The Android apk is constructed from java SDK,Android SDK and .NET SDK.
  • Open android sdk manager,go to Tools>Android>Android SDK Manager...
  • then now choose the latest android Sdk and install it,choose these terms in tool Section:

  1. Android SDK Tools
  2. Android  SDK Platforms-Tools
  3. Android SDK Build Tools(choose the latest version).

  •     Now download latest Platform in platform section.

    5 Installing Emulators:

        Emulators are the virtual mobiles which are use for testing purpose and run in local machines.these are act as a same as a physical mobile.

  • iOS Emulators
  1. iOS Emulators are genrated and run through Xcode which is use by xamarin for testing iOS Emulators supports rotation,ScreenShot capturing and pressure sensors etc.
  2. iOS Emulators can be usable in Visual Studio for Windows through remote mac egent but in reality it work in mac System.

  • Android Emulators
     In Previous section,we download all SDK so here we just download emulators and setting up them.

  • In android Sdk Manager,go to Tools Section and check android emulator.
  • then now open Android Device Manager.go to Tools>Android>Android Device Manager...
  • Now,you will get a Android Device manager screen 
  • here,you can manage all device which you are already created and create new devices and set the specification as you need
  • here specify all configuration of your emulator then click create button
  • Now your emulator is ready for testing your xamarin App.

Conclusion:

  These step are sufficient for installing xamarin in your local device. now you able to create,build and deploy xamarin cross platform mobile app here we also understand how to build emulator for xamarin.android and xamarin.ios which also able us for testing purpose.

Implementation of Font awesome

Introduction     Hello All Today we will understand how to add icon or images with help of font  awesome.Font awesome is a font fa...