亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

更新應用程序時如何讓所有現有用戶退出 Google?

更新應用程序時如何讓所有現有用戶退出 Google?

慕神8447489 2023-05-10 17:03:05
我正在嘗試將 Google Play 游戲服務集成到我的應用程序中。(我真的遇到了麻煩,所以請也看看這個問題。)實際上我一直在使用使用 Web 客戶端 ID 的 Google 登錄,并試圖將其切換到使用 Android 客戶端 ID 的 Google Play 游戲。我想知道的是讓每個用戶在用戶更新應用程序時注銷。否則,如果用戶已經使用網絡客戶端 ID 登錄并嘗試使用 Google Play 游戲功能,應用程序會崩潰。我該如何處理這個問題?
查看完整描述

1 回答

?
皈依舞

TA貢獻1851條經驗 獲得超3個贊

您需要創建一個初始檢查構建版本的啟動活動


創建一個 Splash 活動并將此方法添加到其中。


        public class SplashScreen extends AppCompatActivity {

            @Override

            protected void onCreate(@Nullable Bundle savedInstanceState) {

                super.onCreate(savedInstanceState);

                setContentView(R.layout.splash_activity);


                new Handler().postDelayed(new Runnable() {

                    @Override

                    public void run() {

                      forcedLogout();

                    }

                },5*1000);

            }

        }


            private void forcedLogout(){


                if (myPrefs.getLong(PREF_APP_CURRENT_VERSION,0) != BuildConfig.VERSION_CODE){

                    //call logout method

                 }else{

                        startActivity(new Intent(SplashScreen.this,MainActivity.class));


                        finish();

    }

}

然后在您的登錄活動中添加共享首選項。


SharedPreferences.Editor prefEditor = myPrefs.edit();

prefEditor.putLong(PREF_APP_CURRENT_VERSION,BuildConfig.VERSION_CODE);

prefEditor.commit();


查看完整回答
反對 回復 2023-05-10
  • 1 回答
  • 0 關注
  • 161 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號