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


Java ConnectionResult类代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:OlayinkaPeter,项目名称:Toodoo,代码行数:26,代码来源:ToodooCamera.java

示例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();
    }
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:27,代码来源:MosquesActivity.java

示例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);
        }
    }
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:25,代码来源:BaseCastManager.java

示例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();
    }
}
 
开发者ID:mkeresztes,项目名称:AndiCar,代码行数:26,代码来源:SecureBackupJob.java

示例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));
    }
}
 
开发者ID:Augugrumi,项目名称:SpaceRace,代码行数:18,代码来源:AbsRoomActivity.java

示例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();
    }
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:27,代码来源:FusedLocationService.java

示例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;
        }
    }
}
 
开发者ID:dvdciri,项目名称:DeepImagePreview-Project,代码行数:24,代码来源:ScanFragment.java

示例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));
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:20,代码来源:JobSchedulerTest.java

示例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();
    }
}
 
开发者ID:claudiodegio,项目名称:dbsync,代码行数:17,代码来源:TestGDriveActivity.java

示例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();
    }
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:23,代码来源:LocatrActivity.java

示例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;
}
 
开发者ID:jefflinwood,项目名称:twilio-voice-phonegap-plugin,代码行数:22,代码来源:TwilioVoicePlugin.java

示例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;
}
 
开发者ID:squareboat,项目名称:Excuser,代码行数:21,代码来源:SplashActivity.java

示例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;
        }
    }
}
 
开发者ID:volkansahin45,项目名称:Moneycim,代码行数:26,代码来源:OcrCaptureActivity.java

示例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;
}
 
开发者ID:pedromassango,项目名称:Programmers,代码行数:17,代码来源:GoogleServices.java

示例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();
    }
}
 
开发者ID:plweegie,项目名称:piast-trail,代码行数:22,代码来源:PlaceListFragment.java


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