// Gets vehicle images data from the passed URL.
        private async Task <VehicleUKData> GetVehicleImagesfromAPIAsync(string url)
        {
            try
            {
                // Create an HTTP web request using the URL:
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
                request.ContentType = "application/json";
                request.Method      = "GET";

                // Send the request to the server and wait for the response:
                using (WebResponse response = await request.GetResponseAsync())
                {
                    // Get a stream representation of the HTTP web response:
                    using (Stream stream = response.GetResponseStream())
                    {
                        string       responseString = string.Empty;
                        StreamReader reader         = new StreamReader(stream);
                        responseString = reader.ReadToEnd();
                        stream.Flush();

                        VehicleUKData obj = null;
                        if (responseString != "")
                        {
                            //Converting JSON Array Objects into generic list
                            obj = JsonConvert.DeserializeObject <VehicleUKData>(responseString);
                        }

                        return(obj);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                //return null;
            }
            return(null);
        }
        private async void DownLoadVehicleImages(string strRegNo)
        {
            if (CommonFunctions.IsNetworkConnected())
            {
                //km12akk
                // Get the latitude and longitude entered by the user and create a query.km12akk";//
                string url = "https://uk1.ukvehicledata.co.uk/api/datapackage/VehicleImageData?v=2&api_nullitems=1&auth_apikey=a418b0ad-33ab-4953-9a00-9d3ea8a12319&key_VRM=" + strRegNo;

                // Fetch the vehicle information asynchronously,
                // parse the results, then update the screen:
                objVehicleImageList = await GetVehicleImagesfromAPIAsync(url);

                if (objVehicleImageList != null)
                {
                    if (objVehicleImageList.Response.StatusCode.Equals("Success"))
                    {
                        if (CheckSelfPermission(permission) == (int)Permission.Granted)
                        {
                            CommonFunctions.CreateDirectoryForApp();
                            CommonFunctions.CreateDirectoryForRegNo(strRegNo);

                            //Needed to uncommment
                            for (int i = 0; i < objVehicleImageList.Response.DataItems.VehicleImages.ImageDetailsList.Count(); i++)
                            {
                                try
                                {
                                    string _RealVehicleImageName = String.Format("_{0}.png", i + 1);
                                    string _RealVehicleImagePath = Android.OS.Environment.ExternalStorageDirectory + "/RentACar" + "/" + strRegNo + "/" + _RealVehicleImageName;
                                    // Load image synchronously
                                    //// Bitmap bmp = imageLoader.LoadImageSync(objVehicleImageList.Response.DataItems.VehicleImages.ImageDetailsList[i].ImageUrl);
                                    Bitmap imageBitmap = CommonFunctions.GetBitmapFromUrl(objVehicleImageList.Response.DataItems.VehicleImages.ImageDetailsList[i].ImageUrl);
                                    var    stream      = new System.IO.FileStream(_RealVehicleImagePath, System.IO.FileMode.Create);
                                    imageBitmap.Compress(Bitmap.CompressFormat.Png, 100, stream);
                                    stream.Flush();
                                    stream.Close();
                                }
                                catch (Exception ex)
                                {
                                    // TODO: handle exception
                                }
                                finally
                                {
                                }
                            }
                        }
                        else
                        {
                            GetExternalStoragePermissionAsync();
                        }
                    }
                    else
                    {
                    }
                }
            }
            else
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetMessage("Please enable internet to get vehicle images from API.");
                alert.SetNeutralButton("OK", delegate { });
                alert.Create().Show();
            }
            //this.progressLayout.Visibility = ViewStates.Gone;
        }