Ejemplo n.º 1
0
        public void OnLocationChanged(Android.Locations.Location location)
        {
            Log.Debug(tag, "Location changed");
            latitude = location.Latitude.ToString();
            longitude = location.Longitude.ToString();
            provider = location.Provider.ToString();
            //SendNotification(latitude);
            if(locSent == false)
            {
                API apiCall = new API();
                apiCall.addReport("<a href=\"http://www.google.com/maps/place/" + latitude + "," + longitude + "/@" + latitude + "," + longitude + ",17z\">Location (" + latitude + ";" + longitude + ")</a>");
                apiCall.LastLocation(latitude + ", " + longitude);
                locSent = true;
            }

            StopSelf();
        }
        public override void OnReceive(Context context, Intent intent)
        {
            if ((intent.Action != null) && (intent.Action == Intent.ActionBootCompleted))
            {

                Android.App.Application.Context.StartService(new Intent(Android.App.Application.Context, typeof(KotysService)));
                API callApi = new API();
                try
                {
                    callApi.addReport("Device booted");
                }
                catch(Exception s)
                {

                }
            }
        }
Ejemplo n.º 3
0
        public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId)
        {
            locMgr = GetSystemService(Context.LocationService) as LocationManager;

            if (locMgr.AllProviders.Contains(LocationManager.NetworkProvider)
                && locMgr.IsProviderEnabled(LocationManager.NetworkProvider))
            {
                locMgr.RequestLocationUpdates(LocationManager.NetworkProvider, 2000, 1, this);
            }
            else
            {
                API apiCall = new API();
                apiCall.addReport("GPS is disabled");
                StopSelf();

            }

            return StartCommandResult.NotSticky;
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.LoggedIn);

            Button buttonToReg = FindViewById<Button>(Resource.Id.buttonToReg);
            buttonToReg.Click += (sender, e) =>
            {

                var intent = new Intent(this, typeof(RegDevActivity));

                StartActivityForResult(intent,0);

            };

            Button button1 = FindViewById<Button>(Resource.Id.button1);
            button1.Click += (sender, e) =>
            {
                Toast.MakeText(this, "Logged out", ToastLength.Long).Show();

                Finish();

            };

            Button buttonUpdate = FindViewById<Button>(Resource.Id.buttonUpdate);
            buttonUpdate.Click += (sender, e) =>
            {
                API apicall = new API();
                EditText textDevID = FindViewById<EditText>(Resource.Id.editTextDevice);

                string oldDevId = devId;

                if (devId != textDevID.Text)
                {
                    if(apicall.UpdateDevId(devId, textDevID.Text)== true)
                    {
                        Toast.MakeText(this, "The deviceId has been updated", ToastLength.Long).Show();

                        devId = textDevID.Text;

                        //update to SqlLite

                        string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "settingsk.db3");
                        var db = new SQLiteConnection(dbPath);
                        db.CreateTable<Settings>();
                        db.Query<Settings>("update Settings SET devID='"+devId+"' WHERE devID='"+oldDevId+"'");
                        isLogged();
                        //

                    }
                    else
                    {
                        Toast.MakeText(this, "The deviceId was NOT updated", ToastLength.Long).Show();
                    }
                }else
                {
                    Toast.MakeText(this, "The deviceID is unchanged!!", ToastLength.Long).Show();
                }
            };

            isLogged();
        }