[英]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.