本文整理汇总了Java中com.google.android.gms.common.ConnectionResult类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionResult类的具体用法?Java ConnectionResult怎么用?Java ConnectionResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionResult类属于com.google.android.gms.common包,在下文中一共展示了ConnectionResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startCameraSource
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
/**
* Starts or restarts the camera source, if it exists. If the camera source doesn't exist yet
* (e.g., because onResume was called before the camera source was created), this will be called
* again when the camera source is created.
*/
private void startCameraSource() throws SecurityException {
// check that the device has play services available.
int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
getApplicationContext());
if (code != ConnectionResult.SUCCESS) {
Dialog dlg =
GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
dlg.show();
}
if (mCameraSource != null) {
try {
mPreview.start(mCameraSource, mGraphicOverlay);
} catch (IOException e) {
Log.e(TAG, "Unable to start camera source.", e);
mCameraSource.release();
mCameraSource = null;
}
}
}
示例2: startFusedLocation
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
/**
* Start to attach google location services
*/
public void startFusedLocation() {
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnectionSuspended(int cause) {
}
@Override
public void onConnected(Bundle connectionHint) {
}
}).addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult result) {
}
}).build();
mGoogleApiClient.connect();
} else {
mGoogleApiClient.connect();
}
}
示例3: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
@Override
public void onConnectionFailed(ConnectionResult result) {
LOGD(TAG, "onConnectionFailed() reached, error code: " + result.getErrorCode()
+ ", reason: " + result.toString());
disconnectDevice(mDestroyOnDisconnect, false /* clearPersistentConnectionData */,
false /* setDefaultRoute */);
mConnectionSuspended = false;
if (mMediaRouter != null) {
mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
}
for (BaseCastConsumer consumer : mBaseCastConsumers) {
consumer.onConnectionFailed(result);
}
PendingIntent pendingIntent = result.getResolution();
if (pendingIntent != null) {
try {
pendingIntent.send();
} catch (PendingIntent.CanceledException e) {
LOGE(TAG, "Failed to show recovery from the recoverable error", e);
}
}
}
示例4: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
try {
String message = getString(R.string.error_056);
if (connectionResult.getErrorMessage() != null && connectionResult.getErrorMessage().length() > 0)
message = connectionResult.getErrorMessage();
else if (connectionResult.getErrorCode() == ConnectionResult.SIGN_IN_REQUIRED) {
message = getString(R.string.error_121);
}
else if (connectionResult.getErrorCode() == ConnectionResult.SIGN_IN_FAILED) {
message = getString(R.string.error_122);
}
AndiCarNotification.showGeneralNotification(this, AndiCarNotification.NOTIFICATION_TYPE_NOT_REPORTABLE_ERROR,
(int) System.currentTimeMillis(), getString(R.string.pref_category_secure_backup), message, null, null);
if (debugLogFileWriter != null) {
debugLogFileWriter.appendnl("Connection failed: ").append(message);
debugLogFileWriter.flush();
}
} catch (IOException e2) {
e2.printStackTrace();
}
}
示例5: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.d("INTRO", "onConnectionFailed:" + connectionResult);
if (mResolvingConnectionFailure) {
Log.d("CONNECTION", "onConnectionFailed() ignoring connection failure; already resolving.");
return;
}
if (mSignInClicked || mAutoStartSignInFlow) {
mAutoStartSignInFlow = false;
mSignInClicked = false;
mResolvingConnectionFailure = BaseGameUtils.resolveConnectionFailure(this,
SpaceRace.getgAPIClient(),
connectionResult, RC_SIGN_IN, getString(R.string.signin_other_error));
}
}
示例6: startFusedLocation
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
/**
* Start to attach google location services
*/
public void startFusedLocation() {
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(context).addApi(LocationServices.API)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnectionSuspended(int cause) {
}
@Override
public void onConnected(Bundle connectionHint) {
}
}).addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult result) {
}
}).build();
mGoogleApiClient.connect();
} else {
mGoogleApiClient.connect();
}
}
示例7: startCameraSource
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
/**
* Starts or restarts the camera source, if it exists. If the camera source doesn't exist yet
* (e.g., because onResume was called before the camera source was created), this will be called
* again when the camera source is created.
*/
private void startCameraSource() throws SecurityException {
// Check that the device has play services available.
int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(getContext());
if (code != ConnectionResult.SUCCESS) {
Dialog dlg = GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), code, 0);
dlg.show();
}
if (mCameraSource != null) {
try {
mPreview.start(mCameraSource, mOcrGraphicOverlay);
} catch (IOException e) {
Log.e(TAG, "Unable to start camera source.", e);
mCameraSource.release();
mCameraSource = null;
}
}
}
示例8: testSchedulerInApi19
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
@Test
@Config(sdk = Build.VERSION_CODES.KITKAT, shadows = {ShadowGoogleApiAvailability.class})
public void testSchedulerInApi19() {
JobInfo api21Job = JobCreator.create(context, 0).setRequiresCharging(true).build();
JobInfo api24Job = JobCreator.create(context, 3).setPeriodic(15 * 60 * 1000L, 5 * 60 * 1000L).build();
JobInfo api26Job = JobCreator.create(context, 1).setRequiresBatteryNotLow(true).build();
ShadowGoogleApiAvailability.setIsGooglePlayServicesAvailable(ConnectionResult.SERVICE_MISSING);
assertThat(jobScheduler.getSchedulerForJob(context, api21Job), instanceOf(AlarmScheduler.class));
assertThat(jobScheduler.getSchedulerForJob(context, api24Job), instanceOf(AlarmScheduler.class));
assertThat(jobScheduler.getSchedulerForJob(context, api26Job), instanceOf(AlarmScheduler.class));
ShadowGoogleApiAvailability.setIsGooglePlayServicesAvailable(ConnectionResult.SUCCESS);
assertThat(jobScheduler.getSchedulerForJob(context, api21Job), instanceOf(GcmScheduler.class));
assertThat(jobScheduler.getSchedulerForJob(context, api24Job), instanceOf(GcmScheduler.class));
assertThat(jobScheduler.getSchedulerForJob(context, api26Job), instanceOf(AlarmScheduler.class));
}
示例9: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Toast.makeText(this, "onConnectionFailed:" + connectionResult.getErrorMessage(), Toast.LENGTH_SHORT).show();
// Viene chiamata nel caso la connect fallisca ad esempio
// non è ancora stata data autorizzaiozne alla applicazione corrente
if (connectionResult.hasResolution()) {
try {
connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
// Unable to resolve, message user appropriately
}
} else {
GoogleApiAvailability.getInstance().getErrorDialog(this, connectionResult.getErrorCode(), 0).show();
}
}
示例10: onResume
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int errorCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (errorCode != ConnectionResult.SUCCESS) {
Dialog errorDialog = apiAvailability.getErrorDialog(this,
errorCode,
REQUEST_ERROR,
new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
// Leave if services are unavailable.
finish();
}
});
errorDialog.show();
}
}
示例11: checkPlayServices
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
/**
* Check the device to make sure it has the Google Play Services APK. If
* it doesn't, display a dialog that allows users to download the APK from
* the Google Play Store or enable it in the device's system settings.
*/
private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(cordova.getActivity());
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(cordova.getActivity(), resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
.show();
} else {
Log.e(TAG, "This device is not supported for Google Play Services.");
javascriptErrorback(0, "This device is not supported for Google Play Services.", mInitCallbackContext);
}
return false;
}
return true;
}
示例12: checkPlayServices
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
@SuppressLint("LongLogTag")
private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(this, resultCode, 9000, new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
}).show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
示例13: startCameraSource
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
/**
* Starts or restarts the camera source, if it exists. If the camera source doesn't exist yet
* (e.g., because onResume was called before the camera source was created), this will be called
* again when the camera source is created.
*/
private void startCameraSource() throws SecurityException {
// Check that the device has play services available.
int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
getApplicationContext());
if (code != ConnectionResult.SUCCESS) {
Dialog dlg =
GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
dlg.show();
}
if (mCameraSource != null) {
try {
mPreview.start(mCameraSource, mGraphicOverlay);
} catch (IOException e) {
Log.e(TAG, "Unable to start camera source.", e);
mCameraSource.release();
mCameraSource = null;
}
}
}
示例14: isGooglePlayServicesAvailable
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
public boolean isGooglePlayServicesAvailable() {
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
int code = googleApiAvailability.isGooglePlayServicesAvailable(context);
if (code != ConnectionResult.SUCCESS) {
if (googleApiAvailability.isUserResolvableError(code)) {
googleApiAvailability.getErrorDialog(context, code, PLAY_SERVICE_RESOLUTION_REQUEST, this);
} else {
showLog("THIS DEVICE IS NOT SUPPORTED");
Util.killAppProccess();
}
showLog("isGooglePlayServicesAvailable - " + "false");
return false;
}
showLog("isGooglePlayServicesAvailable - " + "true");
return true;
}
示例15: onResume
import com.google.android.gms.common.ConnectionResult; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
updateUI();
//checking if Play Store app installed on device
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int errorCode = apiAvailability.isGooglePlayServicesAvailable(getActivity());
if (errorCode != ConnectionResult.SUCCESS) {
Dialog errorDialog = apiAvailability
.getErrorDialog(getActivity(), errorCode, REQUEST_ERROR,
new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
getActivity().finish();
}
});
errorDialog.show();
}
}