简体   繁体   English

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

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

I am trying to integrate Google Play Game Services into my app. 我正在尝试将Google Play游戏服务集成到我的应用中。 (I am really having trouble with it so please take a look at this question as well..) And I actually have been using Google Sign In which uses Web Client ID and trying to switch it to Google Play Games which uses Android Client ID. (我确实遇到了麻烦,所以也请看一下这个问题 。)实际上,我一直在使用使用Web客户端ID的Google登录,然后尝试将其切换到使用Android客户端ID的Google Play游戏。

What I want to know is having every users sign out when the user updates the app. 我想知道的是让每个用户在用户更新应用程序时退出。 Otherwise if the user already signed in using web client id and try to use Google Play Games functionality, app crashes. 否则,如果用户已经使用Web客户端ID登录并尝试使用Google Play游戏功能,则应用程序将崩溃。

How can I handle this problem? 我该如何解决这个问题?

EDIT : You need to a create Splash Activity which will initially check for the Build Version 编辑 :您需要创建一个初始启动时会检查生成版本的启动活动

Create a Splash Activity and add this method to it. 创建一个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();
    }
}

then add shared preferences in your login activity. 然后在您的登录活动中添加共享的首选项。

SharedPreferences.Editor prefEditor = myPrefs.edit();
prefEditor.putLong(PREF_APP_CURRENT_VERSION,BuildConfig.VERSION_CODE);
prefEditor.commit();

暂无
暂无

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

相关问题 如何为我的Android应用启用Google登录,使其仅允许来自特定Google域的用户登录? - How do I enable Google sign-in for my Android app such that it only allows users from a specific Google domain? 如何在 Firebase 中退出我的 Google 帐户,这样当我再次登录时,我可以选择我想登录的帐户? - How do I log out of my Google Account in Firebase such when I log in again, I can choose the account I would like to sign in with? 将 Firebase 应用与 Google Sign In 结合使用时,如何使用我的 Google Cloud Function 进行身份验证? - How do I authenticate with my Google Cloud Function when using my Firebase App with Google Sign In? 如何从数据库访问所有用户? - How can I access all users from database? 在Google Play商店上发布应用程序后,如果该应用程序依赖于Google登录,该如何测试? - How do I test my app when it's dependent on Google sign in after publishing app on the Google Play Store? 如何过滤掉数据库中所有用户的获取请求,以便具有管理员角色的用户不显示在列表中? - How can I filter out a get request of all users in my DB so that users with an admin role are not shown in the list? 如何在维护期间向Web应用程序用户显示“暂时停止服务”页面? - How can I show a “temporarily out of service” page to web-app users during maintenance? 如何拥有登录Web应用程序的所有用户的列表 - How can I have list of all users logged in my web application 如何从字符串中删除所有HTML - How can I strip out all HTML from my string Android:当我在Sql Server中将状态更改为false时,如何从应用程序自动注销? - Android : How can i Auto Log out from my app when i change my status to false in Sql server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM