Google Play 서비스가 설치되지 않은 오류 대화 상자를 표시하고 사용자를 리디렉션합니다.

N 샤르마

안녕하세요 저는 GCM사용이 Google Play Service설치 되었는지 여부를 확인 해야하는 안드로이드 응용 프로그램에서 사용하려고합니다 . 이를 위해 코딩했지만 사용자가 Google Play Service설치 하지 않은 상황을 처리하는 방법은 없습니다 .

사용자가을 (를) 설치하라는 메시지를 표시하고이를 설치 Google Play Service하기 위해 Play 스토어로 리디렉션 하는 방법이 내장되어 있습니까?

/**
 * 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.
 */
public static boolean checkPlayServices(Context mContext) {
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(mContext);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            GooglePlayServicesUtil.getErrorDialog(resultCode, (Activity)mContext,Constants.PLAY_SERVICES_RESOLUTION_REQUEST).show();
        }
        return false;
    }
    return true;
}

// 여기에서 기기에 Google Play 서비스가 설치되어 있는지 확인합니다. // 설치되어 있으면 기기를 GCM에 등록합니다. // 그렇지 않으면 사용자를 Play 스토어로 리디렉션하여 설치합니다.

        if(Utils.checkPlayServices(getActivity())) {
            new RegisterGCMDeviceAsynTask(new TaskCompleteListener() {

                @Override
                public void onTaskCompleted(String result) {
                    new TeemWurkAsyncTask(new TaskCompleteListener() {

                        @Override
                        public void onTaskCompleted(String result) {
                            Logger.d(TAG, result);
                        }
                    }, Constants.LOGIN_API_CALL).execute("");
                }
            }).execute();
        } else {
            // display the dialog that device do not have Google Play Service installed.

        }
도적

이 같은 :

if(!isGooglePlayServicesAvailable()) {
     GooglePlayServicesUtil.getErrorDialog(9999, this, RQS_GooglePlayServices).show();
}

9999는에서 사용되는 요청 코드 (임의의 정수)입니다 onActivityResult().

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관