当前位置: 首页>>代码示例>>Java>>正文


Java LocationSettingsResult类代码示例

本文整理汇总了Java中com.google.android.gms.location.LocationSettingsResult的典型用法代码示例。如果您正苦于以下问题:Java LocationSettingsResult类的具体用法?Java LocationSettingsResult怎么用?Java LocationSettingsResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocationSettingsResult类属于com.google.android.gms.location包,在下文中一共展示了LocationSettingsResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: displayLocationSettingsRequest

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
public void displayLocationSettingsRequest(final Activity activity) {
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(activity)
            .addApi(LocationServices.API).build();
    googleApiClient.connect();

    LocationRequest locationRequest = LocationRequest.create();
    locationRequest.setPriority(mAccuracy);
    locationRequest.setInterval(mInterval);
    locationRequest.setFastestInterval(mInterval / 2);

    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
            .addLocationRequest(locationRequest);
    builder.setAlwaysShow(false);

    final PendingResult<LocationSettingsResult> result =
            LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build());
    result.setResultCallback(new LocationResultCallback(activity));
}
 
开发者ID:philiWeitz,项目名称:react-native-location-switch,代码行数:19,代码来源:LocationSwitch.java

示例2: onResult

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
@Override
public void onResult(LocationSettingsResult result) {
    final Status status = result.getStatus();
    switch (status.getStatusCode()) {
        case LocationSettingsStatusCodes.SUCCESS:
            // All location settings are satisfied -> nothing to do
            callSuccessCallback();
            break;
        case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
            // Location settings are not satisfied. Show the user a dialog to upgrade location settings
            try {
                // Show the dialog by calling startResolutionForResult(), and check the result
                status.startResolutionForResult(mActivity, REQUEST_CHECK_SETTINGS);
            } catch (IntentSender.SendIntentException e) {
                Log.e(TAG, "PendingIntent unable to execute request.", e);
                callErrorCallback();
            }
            break;
        case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
            Log.e(TAG, "Location settings are inadequate, and cannot be fixed here. Dialog not created.");
            callErrorCallback();
            break;
    }
}
 
开发者ID:philiWeitz,项目名称:react-native-location-switch,代码行数:25,代码来源:LocationSwitch.java

示例3: onConnected

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
@Override
public void onConnected(Bundle bundle) {

    //inicializa list view
    adapter=new ArrayAdapter<Location>(this, android.R.layout.simple_list_item_1, data);
    setListAdapter(adapter);

    //define requisicao para obter localizacao
    //objeto define quantos updates serao necessarios
    //deadline para desistir se nao conseguir obter location
    //intervalo
    //otimizacao de energia, caso aplicavel
    locationRequest = new LocationRequest()
            .setNumUpdates(5)
            .setExpirationDuration(60000)
            .setInterval(1000)
            .setPriority(LocationRequest.PRIORITY_LOW_POWER);


    LocationSettingsRequest.Builder b = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
    PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(playServices, b.build());
    result.setResultCallback(this);
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:24,代码来源:FusedLocationMapActivity.java

示例4: onResult

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
@Override
public void onResult(@NonNull LocationSettingsResult locationSettingsResult) {
  final Status status = locationSettingsResult.getStatus();
  switch (status.getStatusCode()) {
    case LocationSettingsStatusCodes.SUCCESS:
      // All location settings are satisfied. The client can
      // initialize location requests here.
      continueGPSOperation();
      break;
    case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
      // Location settings are not satisfied, but this can be fixed
      // by showing the user a dialog.
      _result.error("LOCATION DISABLED",
              "This Android device has it's location disabled",
              null);
      break;
    case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
      // Location settings are not satisfied. However, we have no way
      // to fix the settings so we won't show the dialog.
      _result.error("LOCATION DISABLED",
              "This Android device has it's location disabled",
              null);
      break;
  }
}
 
开发者ID:Gustash,项目名称:flutter_geolocation,代码行数:26,代码来源:GpsCoordinatesPlugin.java

示例5: onConnected

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
    LocationRequest locationRequest = createLocationRequest();
    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
    PendingResult<LocationSettingsResult> locationSettingsResultPendingResult = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
    locationSettingsResultPendingResult
            .setResultCallback(new ResultCallback<LocationSettingsResult>() {
                @Override
                public void onResult(LocationSettingsResult result) {
                    if (LocationSettingsStatusCodes.SUCCESS != result.getStatus().getStatusCode()) {
                        if (result.getStatus().hasResolution()) {
                            handleLocationStatusResult(result.getStatus());
                        } else {
                            // TODO: faire quelque chose
                        }
                    }
                }
            });
    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // la demande des droits est faite ailleurs
        return;
    }
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
    onLocationChanged(LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient));
}
 
开发者ID:ANFR-France,项目名称:proto-collecte,代码行数:26,代码来源:MainActivity.java

示例6: configureLocationConnection

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
private void configureLocationConnection() {
    LocationRequest locationRequest = createLocationRequest();
    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
    PendingResult<LocationSettingsResult> locationSettingsResultPendingResult = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
    locationSettingsResultPendingResult
            .setResultCallback(new ResultCallback<LocationSettingsResult>() {
                @Override
                public void onResult(LocationSettingsResult result) {
                    if (LocationSettingsStatusCodes.SUCCESS != result.getStatus().getStatusCode()) {
                        Intent localIntent = new Intent(Constants.GOOGLE_API).putExtra(Constants.GOOGLE_API_LOCATION_RESULT, result.getStatus());
                        LocalBroadcastManager.getInstance(ParcoursService.this).sendBroadcast(localIntent);
                    }
                }
            });
    // noinspection MissingPermission : permissions dans le manifest
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
}
 
开发者ID:ANFR-France,项目名称:proto-collecte,代码行数:18,代码来源:ParcoursService.java

示例7: checkLocationSettings

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
/**
 * Check whether gps is turned on or not.
 */
public boolean checkLocationSettings() {
    // In case of a test session don't check settings
    if (((AppRunnest) activity.getApplication()).isTestSession()) {
        return true;
    }

    if (!gpsIsTurnedOn) {
        PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(
                googleApiClient,
                locationSettingsRequest);
        result.setResultCallback(this);
    }

    return gpsIsTurnedOn;
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:19,代码来源:LocationSettingsHandler.java

示例8: onResult

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
@Override
public void onResult(@NonNull LocationSettingsResult r) {

    switch (r.getStatus().getStatusCode()) {
        case LocationSettingsStatusCodes.SUCCESS:
            gpsIsTurnedOn = true;
            break;
        case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
            try {
                r.getStatus().startResolutionForResult(activity, SideBarActivity.REQUEST_CHECK_SETTINGS);
            } catch (IntentSender.SendIntentException ignored) {
                ignored.printStackTrace();
            }
            break;
        case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
            gpsIsTurnedOn = false;
            break;
    }
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:20,代码来源:LocationSettingsHandler.java

示例9: onConnected

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
/**
 * GoogleApiClient interfaces
 */
@Override
public void onConnected(@Nullable Bundle bundle) {
  final LocationRequest locationRequest = LocationRequest.create()
          .setPriority(LocationRequest.PRIORITY_LOW_POWER);

  final LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
          .addLocationRequest(locationRequest)
          .setNeedBle(true);

  final PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());

  result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
    @Override
    public void onResult(@NonNull LocationSettingsResult locationSettingsResult) {
      final Status status = locationSettingsResult.getStatus();
      if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
        try {
          status.startResolutionForResult(getCurrentActivity(), NEAR_LOCATION_SETTINGS_CODE);
        } catch (IntentSender.SendIntentException e) {
          e.printStackTrace();
        }
      }
    }
  });
}
 
开发者ID:nearit,项目名称:react-native-connectivity-status,代码行数:29,代码来源:RNConnectivityStatusModule.java

示例10: onResult

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
@Override
public void onResult(@NonNull LocationSettingsResult locationSettingsResult) {
  final Status status = locationSettingsResult.getStatus();
  switch (status.getStatusCode()) {
    case LocationSettingsStatusCodes.SUCCESS:
      startLocationUpdates();
      break;
    case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
      try {
        status.startResolutionForResult(LocationActivity.this, REQUEST_CHECK_LOCATION_SETTINGS);
      } catch (IntentSender.SendIntentException e) {
        e.printStackTrace();
        Log.i(TAG, "PendingIntent unable to execute request.");
      }
      break;
    case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
      Log.i(TAG, "Location settings are inadequate, and cannot be fixed here. Dialog not created.");
      break;
  }
}
 
开发者ID:drfonfon,项目名称:ITagAntiLost,代码行数:21,代码来源:LocationActivity.java

示例11: onResult

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
@Override
public void onResult(@NonNull LocationSettingsResult result) {
    final Status status = result.getStatus();
    switch (status.getStatusCode()) {
        case LocationSettingsStatusCodes.SUCCESS:
            mLocationActivityListener.onSettingsCheckSuccess();
            break;
        case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
            try {
                startResolvingSettingsProblem(status);
            } catch (IntentSender.SendIntentException e) {
                mLocationActivityListener.onSettingsCheckFailure();
            }
            break;
        default:
            mLocationActivityListener.onSettingsCheckFailure();
            break;
    }
}
 
开发者ID:BottleRocketStudios,项目名称:Android-Continuity,代码行数:20,代码来源:BaseLocationActivity.java

示例12: onResult

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
@Override
public void onResult(LocationSettingsResult result) {
    Status status = result.getStatus();
    switch (status.getStatusCode()) {
        case LocationSettingsStatusCodes.SUCCESS:
            wasSending = JappPreferences.isUpdatingLocationToServer();
            if (!wasSending) {
                showLocationNotification("Japp verzendt je locatie niet!", Color.rgb(244, 66, 66));
            } else {
                showLocationNotification("Japp verzendt je locatie", Color.rgb(113, 244, 66));
            }
            break;
        case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
            if(listener != null) {
                listener.onResolutionRequired(status);
            }
            break;
    }
}
 
开发者ID:RSDT,项目名称:Japp16,代码行数:20,代码来源:LocationService.java

示例13: onResult

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
@Override
public void onResult(LocationSettingsResult result) {
    final Status status = result.getStatus();
    switch (status.getStatusCode()) {
        case LocationSettingsStatusCodes.SUCCESS:
            // All location settings are satisfied. The client can
            // initialize location requests here.
            startLocationUpdates();
            break;
        case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
            // Location settings are not satisfied, but this can be fixed
            // by showing the user a dialog.
            break;
        case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
            // Location settings are not satisfied. However, we have no way
            // to fix the settings so we won't show the dialog.

            break;
    }
}
 
开发者ID:RSDT,项目名称:Japp16,代码行数:21,代码来源:LocationProviderService.java

示例14: onTransact

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
public boolean onTransact(int paramInt1, Parcel paramParcel1, Parcel paramParcel2, int paramInt2)
{
  switch (paramInt1)
  {
  default: 
    return super.onTransact(paramInt1, paramParcel1, paramParcel2, paramInt2);
  case 1598968902: 
    paramParcel2.writeString("com.google.android.gms.location.internal.ISettingsCallbacks");
    return true;
  }
  paramParcel1.enforceInterface("com.google.android.gms.location.internal.ISettingsCallbacks");
  if (paramParcel1.readInt() != 0) {}
  for (LocationSettingsResult localLocationSettingsResult = (LocationSettingsResult)LocationSettingsResult.CREATOR.createFromParcel(paramParcel1);; localLocationSettingsResult = null)
  {
    a(localLocationSettingsResult);
    paramParcel2.writeNoException();
    return true;
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:20,代码来源:fcw.java

示例15: onResult

import com.google.android.gms.location.LocationSettingsResult; //导入依赖的package包/类
@Override
public void onResult(LocationSettingsResult locationSettingsResult) {
    final Status status = locationSettingsResult.getStatus();
    switch (status.getStatusCode()) {
        case LocationSettingsStatusCodes.SUCCESS:
            Log.i(LOG_TAG, "All location settings are satisfied.");
            startLocationUpdates();
            break;
        case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
            Log.i(LOG_TAG, "Location settings are not satisfied. Show the user a dialog to" +
                    "upgrade location settings ");

            try {
                // Show the dialog by calling startResolutionForResult(), and check the result
                // in onActivityResult().
                status.startResolutionForResult(MainActivity.this, REQUEST_CHECK_SETTINGS);
            } catch (IntentSender.SendIntentException e) {
                Log.i(LOG_TAG, "PendingIntent unable to execute request.");
            }
            break;
        case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
            Log.i(LOG_TAG, "Location settings are inadequate, and cannot be fixed here. Dialog " +
                    "not created.");
            break;
    }
}
 
开发者ID:Greplr,项目名称:Greplr_Android,代码行数:27,代码来源:MainActivity.java


注:本文中的com.google.android.gms.location.LocationSettingsResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。