0

일주일 동안이 문제를 해결하려고 노력했지만 아무런 성공도 얻지 못했습니다. 문제는 앱 사용자가 Google 계정에 로그인하지 않고도 구독을 시도하고 Google 로그인 화면으로 안내하지만 사용자가 로그인하고 구독을 구매 한 후에도 Google Play에서 필요하다고 말하면 처리됩니다. Google 계정에 로그인하십시오. 바로이 단계에서 디버깅을하고 AccountManager의 getAccounts()는 사용자가 최근에 추가 한 계정을 포함하여 배열을 반환합니다. 앱을 종료하고 다시 시작한 후에야 Google Play에서 사용자의 Google 계정을 볼 수 있으며 구매가 정상적으로 작동합니다. 어떤 아이디어이 문제를 해결하는 방법? 가 여기에 사용자가 "구매"버튼을 클릭 할 때 호출되는 방법입니다 :Google Play에서 Google 계정에 로그인하고 있음 (인앱 결제)

accountsArray = accountManager.getAccountsByType("com.google"); 
    if(accountsArray != null && accountsArray.length >= 1){ 
     SystemUtils.getCache(this, new CacheUtils.CallBack<Cache>() { 
      @Override 
      public void run(Cache cache) { 
       billingActivityCache = cache; 
      } 
     }); 

     JSONObject payload = null; 
     try { 
      payload = new JSONObject() 
        .put("user", new JSONObject() 
          .put("id", billingActivityCache.getUser().getId() 
          )); 
     } catch (JSONException e) { 
      e.printStackTrace(); 
     } 

     Bundle buyIntentBundle = null; 
     try { 
      buyIntentBundle = mService.getBuyIntent(3, getPackageName(), 
        currentSku, "subs", payload.toString()); 
     } catch (RemoteException e) { 
      e.printStackTrace(); 
     } 

     PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); 
     try { 
      startIntentSenderForResult(pendingIntent.getIntentSender(), 
        BUY_KEY, new Intent(), Integer.valueOf(0), Integer.valueOf(0), 
        Integer.valueOf(0)); 
     } catch (IntentSender.SendIntentException e) { 
      e.printStackTrace(); 
     } 
    } else{ 
     Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT); 
     intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, new String[]{"com.google"}); 
     startActivityForResult(intent, LOGIN_GOOGLE); 
    } 
+0

는이 @Nataliya – AndroidMechanic

+0

에 대한 코드를 보여 그래, 그게 작동하지만, 그때만 애플 리케이션을 다시 시작한 후 –

+0

그래서 그 두 번째로 작업하지만 instantly..right –

답변