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))); }
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))); }