Example #1
0
        protected override void OnActivityResult(int requestCode, Android.App.Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (resultCode == Android.App.Result.Ok && requestCode == 7083)
            {
                double latitude  = data.GetDoubleExtra("Latitude", 0.0);
                double longitude = data.GetDoubleExtra("Longitude", 0.0);
                UIHelper.DelayedToast("Latitude" + latitude, 0);
                UIHelper.DelayedToast("Longitude" + longitude, 0);
            }
            UIHelper.DelayedToast("active", 0);
        }
Example #2
0
        public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId)
        {
            //Parse location info sent to this service from calling activity to make sure there was no error
            Log.Debug("NavUpdateService", "NavUpdateService started");
            startLat = intent.GetDoubleExtra("startLat", -1);
            startLon = intent.GetDoubleExtra("startLon", -1);
            userID   = intent.GetIntExtra("userID", -1);
            lotID    = intent.GetIntExtra("lotID", -1);
            if (startLat == -1 || startLon == -1 || userID == -1 || lotID == -1)
            {
                Toast.MakeText(this, "Received bad info from initiating activity. Please try again.", ToastLength.Long).Show();
            }
            //Build foreground notification to show while service is running then show it
            var notification = new Notification.Builder(this)
                               .SetContentTitle(Resources.GetString(Resource.String.ApplicationName))
                               .SetContentText(GetString(Resource.String.ForeNotificationText))
                               .SetSmallIcon(Resource.Drawable.AutospotsIcon24x24).SetOngoing(true)
                               .Build();

            StartForeground(noteID, notification);
            return(StartCommandResult.Sticky);
        }
Example #3
0
 static object GetValue(Intent intent, string name, Type type)
 {
     switch (Type.GetTypeCode (type)) {
     case TypeCode.String:
         return intent.GetStringExtra (name);
     case TypeCode.Single:
         return intent.GetFloatExtra (name, 0);
     case TypeCode.Double:
         return intent.GetDoubleExtra (name, 0);
     case TypeCode.Int32:
         return intent.GetIntExtra (name, 0);
     default:
         throw new Exception ("Type not supported");
     }
 }