CodeLog

Showing posts with label Xamarin.Android. Show all posts
Showing posts with label Xamarin.Android. Show all posts

StartActivityForResult | OnActivityResult Deprecated in Xamarin Android

Along with androidX support StartActivityForResult and OnActivityResult got dprecated inside Fragment. Here we can see the one of the alternate approach for this deprecated api's in xamarin android.

Below code snippet explains the handling the above mentioned deprecated API's:

Android Keystore based Encryption and Decryption in Xamarin Android

Brief Walkthrough on Android Keystore based app security in Xamarin android

Description
Data security should be considered as  top priority in any application and this is not just for password any sensitive data, app internal files including the database file. Any security breach in app secret data or app unique concepts(USP) can make way to competitors/attackers.  There are plenty of approaches one can choose to secure app private data.

Why Android Keystore based security : In general in any data encryption/decryption we need to provide the public/private keys. here the challenge is how we can secure these keys. Keystore based security provides solution for this issue where it generates and maintains the key dynamically. 

ReOrder the list items by drag and drop in xamarin android using RecyclerView

Brief:  Explanation with simple steps to how to re-order the list items by long press, drag and drop using recycler view in xamarin android.
  



Image Gallery Control using Xamarin Form

Brief: Implementation of Custom gallery control for Xamarin Form explained in a simple steps.


Description: If you have a plan to display image in gallery or in grid format for your Xamarin.Form application then you are in right place now.
You should be able to do so in next 15-20 minutes :). This implementation targets both android and iOS. Now quickly go through with steps.

Bug : Java.Lang.NullPointerException,Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isMutable()' on a null object reference

I have observed this above mentioned bug keeps on hitting when using Xamarin form,UI control "Frame" for android while it executes without any issues for iOS. 

In my previous post discussed about Frame border highlight issues in android. Frame control still has one or other problem with android and still remains a question mark why Xamarin team has not given any fix for this android specific problem.

How to fetch android sqlite db file from device in Mac Xamarin/Visul Studio.

Here i'm going to share one of the simple method to fetch sqlite database file from android device for xamarin or visul studio installed in mac machine. 
Recently when i was checking data stored in the sqlite db from android device, i couldn't do it easily as i fail to run ADB commands from my terminal.

Same if you are fetching DB file from Emulator it is pretty straight forward. 
Launch Device Monitor(Tools-> Device Monitor) 
select Emulator from left pane
select File Explorer from right pane 
Navigate to app data base file-> /data/data/com.appName.MyApp/databases/
Select required database file->"Pull a file from device" option from top right as shown in screen
Copy DB file to machine storage and open using sqlite db browser(http://sqlitebrowser.org/)

To fetch DB from android device using Windows machine we can use the following ADB command

Force Landscape or Portrait for a single page in Xamarin Form.

Device screen orientation in xamarin is usually configured from Host(Android/iOS) project as suggested here . But what if i need to change the screen orientation of one particular screen(say to landscape) in xamarin form and other screens are different (may be portrait), to do so there is no direct options available from xamarin form.
We will do the configuration in host project for the common screen orientation required throughout the application, to do any changes for particular screen need to touch back to the host project settings again because as of now there is no wrapper Form level API’s available. 

For example consider the scenario that my Form project contains the Five screens out of that, for Third screen i need give support for both Portrait and Landscape and for all other remaining screen only in portrait. This can be done in android as follows,

Use the MessageCenter class to send the message from the Form screen for which orientation need to be changed and receive the same from Android MainActivity class.

ThirdPage.xamal.cs
  public partial class ThirdPage : ContentPage
    {
        protected override void OnAppearing()
        { 
            base.OnAppearing(); 
           MessagingCenter.Send(this, "allowLandScapePortrait”);
        }
         //during page close setting back to portrait
        protected override void OnDisappearing()
        {
            base.OnDisappearing(); 
            MessagingCenter.Send(this, "preventLandScape");
        }
    }

ResolveLibraryProjectImport task failed unexpectedly in release mode in xamarin

This above mentioned error i got during my xamarin form project deployment in release mode. 
In my solution i have more then one project and this error indicates that linking between these project has been broken. If you are facing the same issue, then here i have listed out few scenarios that could help you to solve this issue:


1. Select the project in which error is pointing and Check the reference of other project and package. Reference with yellow triangle icon shows the broken reference. just delete it and re-add.
For any other project reference included in the current project, delete the current project reference and add the new one from release folder of that respective project.
 Or
Open "Configuration manager"



Error retrieving parent for item: No resource found that matches the given name...

This is the one of the frequent error we will get during Xamarin android/Form development. Here i have posted the resolution steps for this error in both windows and Mac machines:

Circular progress bar example using xamarin android

In brief: Here you can check the implementation of custom android widget called circular progress bar in steps using xamarin android.

ExpandableListView in xamarin android

Expandable List View is basically used to display the list of data with respective categories. Which has the feature to expand and collapse the items in a category when user touches category title.


Material design tab in xamarin android

Introduction: Here I'm adding one more UI component to Android Material Design introduction series i.e. Tab control using android material design library in xamarin android. 

Xamarin android material design Snackbar customization

Another beautiful component introduced with android material design is Snackbar. Which has the features similar like a Toast message in additional with interaction capability, displays at the bottom of the screen.


Navigation Drawer using material design in Xamarin.Android.

In Brief:  Here you can see the Navigation drawer implementation in Xamarin android with simple steps and reduced code using beautiful material design.




Push notification using Google Cloud Messaging(GCM) in Xamarin.Android

In Brief:
 This Post is regarding the implementation of Remote notification or Push notification using Google cloud messaging.



Custom AlertDialog example in Xamarin.Android

In Brief:
In this post i will discuss about one of the basic and most widely used component in an android development called customized alert dialog. There are several way of implementing it, here i will show custom alertDialog creation using "DialogFragment method" and "Layout inflation to AlertDialog".