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


Java Status.startResolutionForResult方法代码示例

本文整理汇总了Java中com.google.android.gms.common.api.Status.startResolutionForResult方法的典型用法代码示例。如果您正苦于以下问题:Java Status.startResolutionForResult方法的具体用法?Java Status.startResolutionForResult怎么用?Java Status.startResolutionForResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.common.api.Status的用法示例。


在下文中一共展示了Status.startResolutionForResult方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResult

import com.google.android.gms.common.api.Status; //导入方法依赖的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

示例2: handleLocationStatusResult

import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
private void handleLocationStatusResult(@NonNull Status status) {
    if (mResolvingError) {
        // Already attempting to resolve an error.
        return;
    }
    if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {

        try {
            status.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
            // TODO: mieux gérer mResolvingError (attendre la résolution)
            mResolvingError = true;
        } catch (IntentSender.SendIntentException e) {
            // There was an error with the resolution intent. Try again.
            // TODO: mieux notifier le service
            // mGoogleApiClient.connect();
            MainActivity.this.startService(mCollecteServiceIntent);
            mResolvingError = false;
        }

    } else {
        // TODO: couper l'application ?
        mResolvingError = true;
        showErrorDialog(status.getStatusCode());
    }
}
 
开发者ID:ANFR-France,项目名称:proto-collecte,代码行数:26,代码来源:MainActivity.java

示例3: onResult

import com.google.android.gms.common.api.Status; //导入方法依赖的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

示例4: handleIntent

import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
void handleIntent() {
    Status status = getIntent().getParcelableExtra(ARG_STATUS);

    try {
        status.startResolutionForResult(this, REQUEST_CODE_RESOLUTION);
    } catch (IntentSender.SendIntentException | NullPointerException e) {

        setResolutionResultAndFinish(Activity.RESULT_CANCELED);
    }
}
 
开发者ID:TechIsFun,项目名称:RxJava2-weather-example,代码行数:11,代码来源:LocationSettingsActivity.java

示例5: getLocationSettingsResultCallback

import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
@NonNull
private ResultCallback<Result> getLocationSettingsResultCallback() {
    return new ResultCallback<Result>() {
        @Override
        public void onResult(@NonNull Result result) {
            Status status = result.getStatus();
            if (status.getStatusCode() == CommonStatusCodes.SUCCESS) {
                Log.i(TAG, "All location settings are satisfied.");
                Runnable requestUpdatesTask = new OnPermissionsTask();
                if (isConnected()) requestUpdatesTask.run();
                else {
                    mOnConnectedUpdateCallback = requestUpdatesTask;
                    Log.d(TAG, "Google API is not connected. "
                            + "Updates delayed until Google API is connected again.");
                }
            } else if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
                Log.i(TAG, "Location settings are not satisfied. "
                        + "Showing the user a dialog to upgrade location settings.");
                try {
                    setRequestingPermissions(true);
                    // Show the dialog by calling startResolutionForResult(),
                    // and check the result in the onActivityResult() of mContext
                    status.startResolutionForResult(mContext, REQUEST_CHECK_SETTINGS);
                } catch (IntentSender.SendIntentException e) {
                    Log.wtf(TAG, "PendingIntent unable to execute request", e);
                }
            } else if (status.getStatusCode()
                    == LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE) {
                if (checkNetwork()) {
                    Log.w(TAG, "Location settings can't be changed to meet the requirements");
                    setHasPermissions(false);
                    mOnPermissionsChangedListeners.run();
                    setRequestingPermissions(false);
                }
            }
        }
    };
}
 
开发者ID:ArnauBlanch,项目名称:civify-app,代码行数:39,代码来源:LocationAdapter.java

示例6: showLocationsSettingsDialog

import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
@Override
public void showLocationsSettingsDialog(Status status) {
    try {
        status.startResolutionForResult(this, REQUEST_CHECK_LOCATION_SETTINGS);
    } catch (IntentSender.SendIntentException e) {
        e.printStackTrace();
    }
}
 
开发者ID:titanium-codes,项目名称:LocGetter,代码行数:9,代码来源:BaseLocationActivity.java


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