當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。