public void CheckLocationSetting()
        {
            TestTip.Inst.ShowText("RequestLocationUpdatesWithCallback start");
            this.requestType             = CALLBACK;
            mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(new Context());
            mSettingsClient  = LocationServices.getSettingsClient(new Context());
            mLocationRequest = new LocationRequest();
            mLocationRequest.setInterval(5000);
            mLocationRequest.setPriority(102);
            // get LocationSettingsRequest
            LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
            builder.addLocationRequest(mLocationRequest);
            LocationSettingsRequest locationSettingsRequest = builder.build();

            Task task = mSettingsClient.checkLocationSettings(locationSettingsRequest);

            task.addOnSuccessListener(new HmsSuccessListener <LocationSettingsResponse>((LocationSettingsResponse setting) =>
            {
                var status = setting.getLocationSettingsStates();
                TestTip.Inst.ShowText($"isBlePresent :{status.isBlePresent()}");
                TestTip.Inst.ShowText($"isBleUsable :{status.isBleUsable()}");
                TestTip.Inst.ShowText($"isGpsPresent :{status.isGpsPresent()}");
                TestTip.Inst.ShowText($"isGpsUsable :{status.isGpsUsable()}");
                TestTip.Inst.ShowText($"isLocationPresent :{status.isLocationPresent()}");
                TestTip.Inst.ShowText($"isLocationUsable :{status.isLocationUsable()}");
                TestTip.Inst.ShowText($"isNetworkLocationPresent :{status.isNetworkLocationPresent()}");
                TestTip.Inst.ShowText($"isNetworkLocationUsable :{status.isNetworkLocationUsable()}");
            })).addOnFailureListener(new HmsFailureListener((Exception e) => SetSettingsFailuer(e)));
        }
        public void RequestLocationUpdates(int priority, int requestType)
        {
            TestTip.Inst.ShowText("RequestLocationUpdatesWithCallback start");
            this.requestType             = requestType;
            mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(new Context());
            mSettingsClient  = LocationServices.getSettingsClient(new Context());
            mLocationRequest = new LocationRequest();
            mLocationRequest.setInterval(5000);
            mLocationRequest.setPriority(priority);
            // get LocationSettingsRequest
            LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
            builder.addLocationRequest(mLocationRequest);
            LocationSettingsRequest locationSettingsRequest = builder.build();

            Task task = mSettingsClient.checkLocationSettings(locationSettingsRequest);

            task.addOnSuccessListener(new LocationSuccessListener((AndroidJavaObject o) =>
            {
                switch (requestType)
                {
                case CALLBACK:
                    SetCallbackSuccess();
                    break;

                case INTENT:
                    SetIntentSuccess();
                    break;

                case LocationHD:
                    SetHDSuccess();
                    break;
                }
            }));
            task.addOnFailureListener(new HmsFailureListener((Exception e) => SetSettingsFailuer(e)));
        }
Example #3
0
        public void checkLocationSettings()
        {
            TestTip.Inst.ShowText("check location settings start");
            mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(new Context());
            mSettingsClient  = LocationServices.getSettingsClient(new Context());
            mLocationRequest = new LocationRequest();
            mLocationRequest.setInterval(5000);
            mLocationRequest.setPriority(102);
            LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
            builder.addLocationRequest(mLocationRequest);
            LocationSettingsRequest locationSettingsRequest = builder.build();

            Task task = mSettingsClient.checkLocationSettings(locationSettingsRequest);

            task.addOnSuccessListener(new HmsSuccessListener <LocationSettingsResponse>((LocationSettingsResponse locationSettingsResponse) =>
            {
                var locationSettingsStates = locationSettingsResponse.getLocationSettingsStates();
                TestTip.Inst.ShowText($"isBleUsable: {locationSettingsStates.isBleUsable()}");
                TestTip.Inst.ShowText($"isBlePresent: {locationSettingsStates.isBlePresent()}");
                TestTip.Inst.ShowText($"isGpsPresent: {locationSettingsStates.isGpsPresent()}");
                TestTip.Inst.ShowText($"isGpsUsable: {locationSettingsStates.isGpsUsable()}");
                TestTip.Inst.ShowText($"isLocationPresent: {locationSettingsStates.isLocationPresent()}");
                TestTip.Inst.ShowText($"isLocationUsable: {locationSettingsStates.isLocationUsable()}");
                TestTip.Inst.ShowText($"isNetworkLocationPresent: {locationSettingsStates.isNetworkLocationPresent()}");
                TestTip.Inst.ShowText($"isNetworkLocationUsable: {locationSettingsStates.isNetworkLocationUsable()}");
            }));
            task.addOnFailureListener(new HmsFailureListener((Exception e) => SetSettingsFailuer(e)));
        }
Example #4
0
        public void GetLastLocation(bool withAddress)
        {
            mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(new Context());
            try
            {
                Task lastLocation = null;
                if (withAddress)
                {
                    var request = new LocationRequest();
                    request.setPriority(200);
                    lastLocation = mFusedLocationProviderClient.getLastLocationWithAddress(request);
                }
                else
                {
                    lastLocation = mFusedLocationProviderClient.getLastLocation();
                }

                lastLocation.addOnSuccessListener(new HmsSuccessListener <Location>((location) =>
                {
                    if (location == null)
                    {
                        TestTip.Inst.ShowText("getLastLocation onSuccess location is null");
                        return;
                    }

                    TestTip.Inst.ShowText(
                        "getLastLocation onSuccess location[Longitude,Latitude]:" + location.getLongitude() + ","
                        + location.getLatitude());
                })).addOnFailureListener(new HmsFailureListener((Exception e) =>
                {
                    TestTip.Inst.ShowText("getLastLocation onFailure");
                }));
            }
            catch (System.Exception e)
            {
                TestTip.Inst.ShowText("getLastLocation exception:" + e.Message);
            }
        }