Пример #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.main);

            locationButton        = (Button)FindViewById(Resource.Id.location_button);
            locationButton.Click += delegate {
                StartActivity(new Intent(BaseContext, typeof(LocationActivity)));
            };

            // Set up custom preference screen style button
            Button customPreferencesButton = (Button)FindViewById(Resource.Id.push_custom_preferences_button);

            customPreferencesButton.Click += delegate {
                StartActivity(new Intent(BaseContext, typeof(CustomPreferencesActivity)));
            };

            // Set up android built-in preference screen style button
            Button preferencesButton = (Button)FindViewById(Resource.Id.push_preferences_button);

            preferencesButton.Click += delegate {
                StartActivity(new Intent(BaseContext, typeof(PreferencesActivity)));
            };

            boundServiceFilter = new IntentFilter();
            boundServiceFilter.AddAction(UALocationManager.GetLocationIntentAction(UALocationManager.ActionSuffixLocationServiceBound));
            boundServiceFilter.AddAction(UALocationManager.GetLocationIntentAction(UALocationManager.ActionSuffixLocationServiceUnbound));

            apidUpdateFilter = new IntentFilter();
            apidUpdateFilter.AddAction(UAirship.PackageName + IntentReceiver.APID_UPDATED_ACTION_SUFFIX);
        }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.location);

            networkUpdateButton = (Button)FindViewById(Resource.Id.network_update_button);
            gpsUpdateButton     = (Button)FindViewById(Resource.Id.gps_update_button);

            locationFilter = new IntentFilter();
            locationFilter.AddAction(UALocationManager.GetLocationIntentAction(UALocationManager.ActionSuffixLocationUpdate));

            newCriteria          = new Criteria();
            newCriteria.Accuracy = Accuracy.Fine;

            networkUpdateButton.Click += delegate {
                try {
                    UALocationManager.Shared().RecordCurrentLocation();
                } catch (ServiceNotBoundException e) {
                    Logger.Debug(e.Message);
                } catch (RemoteException e) {
                    Logger.Debug(e.Message);
                }
            };

            gpsUpdateButton.Click += delegate {
                try {
                    UALocationManager.Shared().RecordCurrentLocation(newCriteria);
                } catch (ServiceNotBoundException e) {
                    Logger.Debug(e.Message);
                } catch (RemoteException e) {
                    Logger.Debug(e.Message);
                }
            };
        }
Пример #3
0
 void BoundServiceReceiver_OnReceive(Context context, Intent intent)
 {
     if (UALocationManager.GetLocationIntentAction(UALocationManager.ActionSuffixLocationServiceBound).Equals(intent.Action))
     {
         locationButton.Enabled = true;
     }
     else
     {
         locationButton.Enabled = false;
     }
 }
Пример #4
0
        void LocationUpdateReceiver_OnReceive(Context context, Intent intent)
        {
            if (UALocationManager.GetLocationIntentAction(UALocationManager.ActionSuffixLocationUpdate) == intent.Action)
            {
                Location newLocation = (Location)intent.Extras.Get(UALocationManager.LocationKey);

                String text = string.Format("lat: {0}, lon: {1}", newLocation.Latitude, newLocation.Longitude);

                Toast.MakeText(UAirship.Shared().ApplicationContext,
                               text, ToastLength.Long).Show();
            }
        }