Exemplo n.º 1
0
        public async void StartLocationUpdates()
        {
            /*var locationCriteria = new Criteria();
             *
             * locationCriteria.Accuracy = Accuracy.NoRequirement;
             * locationCriteria.PowerRequirement = Power.NoRequirement;
             *
             * var locationProvider = LocMgr.GetBestProvider(locationCriteria, true);
             *
             * LocMgr.RequestLocationUpdates(locationProvider, 0, 20, this);*/

            var request  = new Xamarin.Essentials.GeolocationRequest(Xamarin.Essentials.GeolocationAccuracy.Medium, TimeSpan.FromSeconds(5));
            var location = await Xamarin.Essentials.Geolocation.GetLocationAsync(request);

            if (location != null)
            {
                try
                {
                    WebReference.BasicHttpBinding_IService1 MyClient = new WebReference.BasicHttpBinding_IService1();

                    MyClient.SetLatLon(Android.Provider.Settings.Secure.GetString(Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId), userid, location.Latitude.ToString(), location.Longitude.ToString(), "");

                    StopSelf();
                }
                catch (Exception ex)
                {
                    StartLocationUpdates();
                }
                //GetAddress(userid, location.Latitude, location.Longitude);
            }
        }
Exemplo n.º 2
0
        public void UpdateMarker()
        {
            DataTable dtlatlon = new DataTable();

            WebReference.BasicHttpBinding_IService1 MyClient = new WebReference.BasicHttpBinding_IService1();

            WebReference.TB latlon = new WebReference.TB();
            latlon = MyClient.GetLatLon(sharedPreferences.GetString("deviceid", null));

            dtlatlon = latlon.table;

            theMap.Clear();

            LatLng       latlng = new LatLng(System.Convert.ToDouble(dtlatlon.Rows[0][0].ToString()), System.Convert.ToDouble(dtlatlon.Rows[0][1].ToString()));
            CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, theMap.CameraPosition.Zoom);

            theMap.MoveCamera(camera);
            MarkerOptions options = new MarkerOptions().SetPosition(latlng).SetTitle("Last Update on " + dtlatlon.Rows[0][2].ToString());
            Marker        marker  = theMap.AddMarker(options);

            marker.ShowInfoWindow();
            if (this.PerformRuntimePermissionCheckForLocation(REQUEST_PERMISSIONS_LOCATION))
            {
                InitializeUiSettingsOnMap();
            }
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.registerlistdevices);

            edtdeviceid = FindViewById <EditText>(Resource.Id.deviceid);
            edtuserid   = FindViewById <EditText>(Resource.Id.userid);
            btnsave     = FindViewById <Button>(Resource.Id.btnsave);
            btncancel   = FindViewById <Button>(Resource.Id.btncancel);

            sharedPreferences = this.GetSharedPreferences("sharedprefrences", 0);

            edtdeviceid.Text = sharedPreferences.GetString("registerdeviceid", null);

            btnsave.Click += delegate
            {
                string deviceid = Android.Provider.Settings.Secure.GetString(Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);

                WebReference.BasicHttpBinding_IService1 MyClient = new WebReference.BasicHttpBinding_IService1();

                MyClient.SetListDevice(deviceid, sharedPreferences.GetString("registerdeviceid", null), edtuserid.Text);

                new MainActivity.LoadDataForActivity().ExecuteOnExecutor(AsyncTask.ThreadPoolExecutor);

                Finish();
            };

            btncancel.Click += delegate
            {
                Finish();
            };
        }
Exemplo n.º 4
0
        public void GetData()
        {
            DataTable dt = new DataTable();

            WebReference.BasicHttpBinding_IService1 MyClient = new WebReference.BasicHttpBinding_IService1();
            try
            {
                WebReference.TB emp      = new WebReference.TB();
                string          deviceid = Android.Provider.Settings.Secure.GetString(Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
                emp = MyClient.GetListDevice(deviceid);

                dt = emp.table;


                recyclelist.Clear();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        recyclelist.Add(new GetSet(dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString()));
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 5
0
            protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
            {
                WebReference.BasicHttpBinding_IService1 MyClient = new WebReference.BasicHttpBinding_IService1();
                try
                {
                    WebReference.TB emp      = new WebReference.TB();
                    string          deviceid = Android.Provider.Settings.Secure.GetString(Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
                    emp = MyClient.GetListDevice(deviceid);

                    dt = emp.table;


                    recyclelist.Clear();
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            recyclelist.Add(new GetSet(dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString()));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Snackbar snackbar = Snackbar.Make(findViewById(Android.Resource.Id.Content), "Error Connection", Snackbar.LengthLong);
                    snackbar.Show();
                }
                return(null);
            }
Exemplo n.º 6
0
 void SendRegistrationToServer(string token)
 {
     sharedPreferences = GetSharedPreferences("sharedprefrences", 0);
     WebReference.BasicHttpBinding_IService1 MyClient = new WebReference.BasicHttpBinding_IService1();
     WebReference.KeyFCM empfcm = new WebReference.KeyFCM();
     empfcm = MyClient.SetKeyFCM(Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId), token);
     // send this token to server
 }
Exemplo n.º 7
0
        void OnItemClick(object sender, int position)
        {
            DataTable dt = new DataTable();

            string parentdeviceid = recyclelist[position].getparentdeviceid();
            string userid         = recyclelist[position].getuserid();
            var    appid          = "AAAAIS9WtFE:APA91bF_EYn_n1l50-PUDfn9RIjZhj7TT4e_02aB15eKc-mlSCZCLU-Q7NQDFH21Wflg-rIQ1WNlZoIhT94hwxrAvLKAkFg6_KjF1Gv2UcIeJ94Q93HHJC9JMANbl5BUjpaFtXca0_yb";
            var    senderid       = "142528132177";

            WebReference.BasicHttpBinding_IService1 notif = new WebReference.BasicHttpBinding_IService1();

            WebReference.TB key = new WebReference.TB();
            key = notif.GetKeyFCM(parentdeviceid);

            dt = key.table;

            ISharedPreferencesEditor keyfcm = sharedPreferences.Edit();

            keyfcm.PutString("keyfcm", dt.Rows[0][0].ToString());
            keyfcm.PutString("deviceid", parentdeviceid);
            keyfcm.PutString("userid", userid);
            keyfcm.Commit();

            notif.PushNotification(appid, senderid, dt.Rows[0][0].ToString(), "start", userid);

            DataTable dtlatlon = new DataTable();

            WebReference.TB latlon = new WebReference.TB();
            latlon = notif.GetLatLon(parentdeviceid);

            dtlatlon = latlon.table;

            ISharedPreferencesEditor editor = sharedPreferences.Edit();

            editor.PutString("lat", dtlatlon.Rows[0][0].ToString());
            editor.PutString("lon", dtlatlon.Rows[0][1].ToString());
            editor.PutString("update", dtlatlon.Rows[0][2].ToString());
            editor.Commit();


            Intent ij = new Intent(this, typeof(MyLocationActivity));

            StartActivity(ij);
        }
Exemplo n.º 8
0
        public async void GetAddress(string userid, double lat, double lon)
        {
            var URL          = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + lon + "&key=AIzaSyCyS0sAM18a1JhzYSwZEBkfyE5--qFoN1U";
            var myHttpClient = new HttpClient();
            var response     = await myHttpClient.GetAsync(URL);

            var json = response.Content.ReadAsStringAsync().Result;

            DataList ObjDataList = new DataList();

            ObjDataList = JsonConvert.DeserializeObject <DataList>(json);
            var address = ObjDataList.results[1].formatted_address;


            WebReference.BasicHttpBinding_IService1 MyClient = new WebReference.BasicHttpBinding_IService1();

            MyClient.SetLatLon(Android.Provider.Settings.Secure.GetString(Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId), userid, lat.ToString(), lon.ToString(), address);

            StopSelf();
        }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.MyLocationLayout);

            sharedPreferences = this.GetSharedPreferences("sharedprefrences", 0);

            this.AddMapFragmentToLayout(Resource.Id.map_container);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            refresh        = toolbar.FindViewById <Button>(Resource.Id.refresh);
            refresh.Click += delegate
            {
                theMap.Clear();

                LatLng       latlng = new LatLng(System.Convert.ToDouble(sharedPreferences.GetString("lat", null)), System.Convert.ToDouble(sharedPreferences.GetString("lon", null)));
                CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, theMap.CameraPosition.Zoom);
                theMap.MoveCamera(camera);
                MarkerOptions options = new MarkerOptions().SetPosition(latlng).SetTitle("Waiting Location Update");
                Marker        marker  = theMap.AddMarker(options);
                marker.ShowInfoWindow();
                if (this.PerformRuntimePermissionCheckForLocation(REQUEST_PERMISSIONS_LOCATION))
                {
                    InitializeUiSettingsOnMap();
                }

                DataTable dt = new DataTable();

                var appid    = "AAAAIS9WtFE:APA91bF_EYn_n1l50-PUDfn9RIjZhj7TT4e_02aB15eKc-mlSCZCLU-Q7NQDFH21Wflg-rIQ1WNlZoIhT94hwxrAvLKAkFg6_KjF1Gv2UcIeJ94Q93HHJC9JMANbl5BUjpaFtXca0_yb";
                var senderid = "142528132177";

                WebReference.BasicHttpBinding_IService1 notif = new WebReference.BasicHttpBinding_IService1();

                var a = sharedPreferences.GetString("keyfcm", null);
                var b = sharedPreferences.GetString("userid", null);

                notif.PushNotification(appid, senderid, sharedPreferences.GetString("keyfcm", null), "start", sharedPreferences.GetString("userid", null));
            };
        }
Exemplo n.º 10
0
        public async void GetAddress(string userid, double lat, double lon)
        {
            var URL          = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + lon + "&key=AIzaSyCyS0sAM18a1JhzYSwZEBkfyE5--qFoN1U";
            var myHttpClient = new HttpClient();
            var response     = await myHttpClient.GetAsync(URL);

            var json = response.Content.ReadAsStringAsync().Result;

            DataList ObjDataList = new DataList();

            ObjDataList = JsonConvert.DeserializeObject <DataList>(json);
            var address = ObjDataList.results[1].formatted_address;


            WebReference.BasicHttpBinding_IService1 MyClient = new WebReference.BasicHttpBinding_IService1();

            MyClient.SetLatLon(Android.Provider.Settings.Secure.GetString(Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId), userid, lat.ToString(), lon.ToString(), address);


            /*sharedPreferences = Application.Context.GetSharedPreferences("sharedprefrences", 0);
             *
             * DataTable dtlatlon = new DataTable();
             * string deviceid = Android.Provider.Settings.Secure.GetString(Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
             *
             * WebReference.BasicHttpBinding_IService1 notif = new WebReference.BasicHttpBinding_IService1();
             *
             * WebReference.TB latlon = new WebReference.TB();
             * latlon = notif.GetLatLon(deviceid);
             *
             * dtlatlon = latlon.table;
             *
             * ISharedPreferencesEditor editor = sharedPreferences.Edit();
             * editor.PutString("lat", dtlatlon.Rows[0][0].ToString());
             * editor.PutString("lon", dtlatlon.Rows[0][1].ToString());
             * editor.Commit();
             *
             * Intent ij = new Intent(global::Android.App.Application.Context, typeof(MyLocationActivity));
             * global::Android.App.Application.Context.StartActivity(ij);*/
        }