2016-07-17 3 views
0

Google 로그인에서 로그 아웃을 클릭하면 android force stop이 중지됩니다. Google 로그인에서 로그 아웃을 클릭하면 android force stop이 중지됩니다.

때 로그 아웃 버튼을 내 응용 프로그램 사용자의 클릭 할 때 사용자 ya 또는 ok

이 내 코드를 클릭 난, 기능 confirmationbox 전화 사용자 ya 또는 ok 그래서 사용자가 로그 아웃됩니다 클릭하면하지만 지금은 중지를 강제

private void confirmationBox() { 
     final AlertDialog.Builder builder = new AlertDialog.Builder(this); 
     builder.setMessage("Apakah Anda Yakin?") 
       .setCancelable(false) 
       .setPositiveButton("Ya", new DialogInterface.OnClickListener() { 
        public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) { 
         Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback(
           new ResultCallback<Status>() { 
            @Override 
            public void onResult(Status status) { 

            } 
           }); 
         session.logoutUser(); 
         Intent intent = new Intent(getApplicationContext(),LoginActivity.class); 
         startActivity(intent); 
         finish(); 
        } 
       }) 
       .setNegativeButton("Tidak", new DialogInterface.OnClickListener() { 
        public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) { 
         dialog.cancel(); 
        } 
       }); 
     final AlertDialog alert = builder.create(); 
     alert.show(); 
    } 
GoogleSignInOption

private void setGoogleSignInAccount() { 
     // Configure sign-in to request the user's ID, email address, and basic profile. ID and basic profile are included in DEFAULT_SIGN_IN. 
     GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) 
       .requestEmail() 
       .build(); 

     // Build a GoogleApiClient with access to the Google Sign-In API and the options specified by gso. 
     mGoogleApiClient = new GoogleApiClient.Builder(this) 
       .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) 
       .addConnectionCallbacks(this) 
       .addOnConnectionFailedListener(this) 
       .addApi(LocationServices.API) 
       .build(); 
    } 

이 내 logca입니다 t

07-17 10:47:55.871 26064-26064/com.emergency.e_place E/AndroidRuntime: FATAL EXCEPTION: main 
                     Process: com.emergency.e_place, PID: 26064 
                     java.lang.NullPointerException: Appropriate Api was not requested. 
                      at com.google.android.gms.common.internal.zzx.zzb(Unknown Source) 
                      at com.google.android.gms.common.api.internal.zzj.zza(Unknown Source) 
                      at com.google.android.gms.common.api.internal.zzg.zza(Unknown Source) 
                      at com.google.android.gms.common.api.internal.zzg.zzb(Unknown Source) 
                      at com.google.android.gms.common.api.internal.zzl.zzb(Unknown Source) 
                      at com.google.android.gms.common.api.internal.zzj.zzb(Unknown Source) 
                      at com.google.android.gms.auth.api.signin.internal.zzc.revokeAccess(Unknown Source) 
                      at com.emergency.e_place.MainActivity$10.onClick(MainActivity.java:832) 
                      at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:153) 
                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                      at android.os.Looper.loop(Looper.java:146) 
                      at android.app.ActivityThread.main(ActivityThread.java:5511) 
                      at java.lang.reflect.Method.invokeNative(Native Method) 
                      at java.lang.reflect.Method.invoke(Method.java:515) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
                      at dalvik.system.NativeStart.main(Native Method) 
+0

'적절한 API를 참조하십시오 - 당신은 그게 무슨 뜻인지 연구 적이 있습니까? –

+0

예 예, 알고 있지만 이해할 수 없음 –

+0

GoogleSignInOptions을 신고 한 방법을 [mcve]로 표시하십시오 –

답변

1

로그인 API가 누락되었습니다. 이 행은 코드에 있어야합니다.

.addApi(Auth.GOOGLE_SIGN_IN_API 

는 requested`되지 않은 how to setup the Sign In API

관련 문제