繁体   English   中英

更新应用程序时,如何让所有现有用户退出Google?

[英]How can I have all existing users sign out from Google when updating the app?

我正在尝试将Google Play游戏服务集成到我的应用中。 (我确实遇到了麻烦,所以也请看一下这个问题 。)实际上,我一直在使用使用Web客户端ID的Google登录,然后尝试将其切换到使用Android客户端ID的Google Play游戏。

我想知道的是让每个用户在用户更新应用程序时退出。 否则,如果用户已经使用Web客户端ID登录并尝试使用Google Play游戏功能,则应用程序将崩溃。

我该如何解决这个问题?

编辑 :您需要创建一个初始启动时会检查生成版本的启动活动

创建一个Splash Activity并将此方法添加到其中。

        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();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM