Tuesday 9 February 2016

Bundle Class in Xamarin.Android


bundle class.jpg
Hello All,
In this we will discuss about one of the most important part of the building blocks of Xamarin.Android, and that is Bundle class.
A Bundle class. in nothing but a mapping from values of String types to various other types that can be Parcelable. While transitioning between the states of life cycle of an Activity class, there is a built in functionality to save the states of the application or to save certain aspects of our application and that is with the help of Bundle but Bundle can also be used in many other ways as we saw earlier that while calling the OnCreate() Method, we passes a Bundle and one way to check whether your application is just started again or its just a initial run of your application, we can check that by the value of the Bundle which is initially null, when your application runs for the first time.
  1. protected override void OnCreate(Bundle initialBundle)
  2. {
  3.  base.OnCreate(initialBundle);
  4. }
So Bundle can also be think of a simple ways to save the state data and simple peace of data of primitive types. So for the example of that we can run below code and check the value of the bundle.
  1. protected override void OnSaveInstanceState(Bundle Initialbundle)
  2. {
  3.     Initialbundle.PutInt("Count", 1);
  4.     base.OnSaveInstanceState(Initialbundle);
  5. }


To view the Full Blog about Bundle Class in Xamarin.Android visit FindNerd.

Also visit Findnerd to read and post tech blogs and can also Ask tech Query over Findnerd.

No comments:

Post a Comment