コード例 #1
0
ファイル: LocationService.cs プロジェクト: smit1712/explore
        public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId)
        {
            const int pendingIntentId = 0;
            Intent    Mainintent      = new Intent(this, typeof(MainActivity));

            pendingIntent = PendingIntent.GetActivity(this, pendingIntentId, Mainintent, PendingIntentFlags.OneShot);

            //StartForegroundService();
            // This method executes on the main thread of the application.
            var notification = new Notification.Builder(this)
                               .SetContentTitle(Resources.GetString(Resource.String.app_name))
                               .SetContentText(Resources.GetString(Resource.String.notification_text))
                               .SetSmallIcon(Resource.Drawable.ic_explore_black_18dp)
                               .SetContentIntent(pendingIntent)
                               .SetOngoing(true)
                               //.AddAction(BuildRestartTimerAction())
                               //.AddAction(BuildStopServiceAction())
                               .Build();

            StartForeground(SERVICE_RUNNING_NOTIFICATION_ID, notification);

            LocationManager = (LocationManager)GetSystemService(LocationService);
            SD  = new SaveData();
            GPS = new mygps(LocationManager, this, SD);

            Timer Btimer = new System.Timers.Timer();

            Btimer.Interval  = 30000;
            Btimer.Elapsed  += Ontimedevent;
            Btimer.AutoReset = true;
            Btimer.Enabled   = true;


            return(StartCommandResult.Sticky);
        }
コード例 #2
0
        private void Updateinfotext()
        {
            WikipediaAPI WAPI = new WikipediaAPI();

            LocationManager = (LocationManager)GetSystemService(LocationService);
            mygps gps = new mygps(LocationManager, this, SD);

            infotext.Text = WAPI.Getinfo(gps.GetAddress(), gps.GetCountry());
            Country       = gps.GetCountry();
            //infotext.Text = WAPI.Getinfo("Harlingen");
            infotext.TextSize = 20;
        }
コード例 #3
0
        public void OpenPlaces()
        {
            MainLayout.Visibility    = ViewStates.Gone;
            VisitedLayout.Visibility = ViewStates.Gone;
            placesLayout.Visibility  = ViewStates.Visible;
            PlacesAPI     places = new PlacesAPI();
            mygps         gps    = new mygps(LocationManager, this, SD);
            List <string> Points = new List <string>();

            Points = places.Getinfo(gps.GetCoordinate(), "museum");
            Points.AddRange(places.Getinfo(gps.GetCoordinate(), "cafe"));
            Points.AddRange(places.Getinfo(gps.GetCoordinate(), "restaurant"));
            if (Points.Count == 0)
            {
                string error = "Could Find any interesting places or no connection to google!";
                Points.Add(error);
            }
            ArrayAdapter <string> arrayAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, Points);

            placeslistview.Adapter = arrayAdapter;
        }