更新并注销 Android
Update and log out Android
我有一个问题:当我在 Google Play 商店发送我的应用程序的新更新并且用户安装它时,是否有可能注销 his/her 应用程序会话? (这意味着将 him/her 直接发送到登录屏幕)
我有这个注销功能:
public void logoutUser() {
pref = PreferenceManager.getDefaultSharedPreferences(this);
editor = pref.edit();
editor.clear();
editor.commit();
alarmMgr = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
Intent alarm = new Intent(getApplicationContext(), AlarmReceiver.class);
pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, alarm, 0);
alarmMgr.cancel(pendingIntent);
Intent intent = new Intent(Activity3.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
谢谢:)
一个选项是使用您的应用程序版本代码
import com.yourpackage.BuildConfig;
...
int versionCode = BuildConfig.VERSION_CODE;
当您的应用程序启动时,检查您的 SQLite 数据库或 SharedPreferences 中的版本号,如果不存在或较低,则应用程序已更新,存储新版本号并注销用户。每次启动应用时检查当前版本代码是否高于存储的版本代码。
来自https://developer.android.com/guide/topics/manifest/manifest-element.html
android:versionCode
An internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute.
The value must be set as an integer, such as "100". You can define it however you want, as long as each successive version has a higher number....
我有一个问题:当我在 Google Play 商店发送我的应用程序的新更新并且用户安装它时,是否有可能注销 his/her 应用程序会话? (这意味着将 him/her 直接发送到登录屏幕)
我有这个注销功能:
public void logoutUser() {
pref = PreferenceManager.getDefaultSharedPreferences(this);
editor = pref.edit();
editor.clear();
editor.commit();
alarmMgr = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
Intent alarm = new Intent(getApplicationContext(), AlarmReceiver.class);
pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, alarm, 0);
alarmMgr.cancel(pendingIntent);
Intent intent = new Intent(Activity3.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
谢谢:)
一个选项是使用您的应用程序版本代码
import com.yourpackage.BuildConfig;
...
int versionCode = BuildConfig.VERSION_CODE;
当您的应用程序启动时,检查您的 SQLite 数据库或 SharedPreferences 中的版本号,如果不存在或较低,则应用程序已更新,存储新版本号并注销用户。每次启动应用时检查当前版本代码是否高于存储的版本代码。
来自https://developer.android.com/guide/topics/manifest/manifest-element.html
android:versionCode
An internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute. The value must be set as an integer, such as "100". You can define it however you want, as long as each successive version has a higher number....