如何使用android处理laucher的活动
我有3个页面,Login,Splash和MainActivity,因此如果用户没有登录,它必须在启动后打开登录页面,因此在我的Splash中,我会检查领域数据库是否有一个字段被填充,如果有,这意味着用户已经登录,但如果没有,则会打开登录页面并正常工作,但是,如果用户退出应用程序(而不是完成应用程序),只需退出并删除配置上的数据,那么当他返回应用程序时,如何处理此问题?它将在如何使用android处理laucher的活动,android,Android,我有3个页面,Login,Splash和MainActivity,因此如果用户没有登录,它必须在启动后打开登录页面,因此在我的Splash中,我会检查领域数据库是否有一个字段被填充,如果有,这意味着用户已经登录,但如果没有,则会打开登录页面并正常工作,但是,如果用户退出应用程序(而不是完成应用程序),只需退出并删除配置上的数据,那么当他返回应用程序时,如何处理此问题?它将在OnPause?有没有其他方法可以避免用户删除数据 @Override protected void onPause() {
OnPause
?有没有其他方法可以避免用户删除数据
@Override
protected void onPause() {
String token_result = new Realmbase().RetrieveToken(CurrentActivity.this);
if(token_result.equals("NODATA")){
Intent i = new Intent(getApplicationContext(),Login.class);
startActivity(i);
finish();
}
else {
//Continue in the same Activity
}
super.onPause();
}
1) 将进程ID保存在共享首选项中:
SharedPreferencesUtils.getInstance().putInt(SharedPreferencesUtils.APP_PROCESS_ID, android.os.Process.myPid());
2) 从最近的任务中清除后从启动器启动应用程序时,请执行以下操作:
int previousProcessID = mSharedPreferencesUtils.getInt(SharedPreferencesUtils.APP_PROCESS_ID);
int currentProcessID = android.os.Process.myPid();
if ((previousProcessID == currentProcessID)) {
// This ensures application not killed yet either by clearing recent or anyway
} else {
// This ensures application killed either by clearing recent or by anyother means
}
int previousProcessID = mSharedPreferencesUtils.getInt(SharedPreferencesUtils.APP_PROCESS_ID);
int currentProcessID = android.os.Process.myPid();
if ((previousProcessID == currentProcessID)) {
// This ensures application not killed yet either by clearing recent or anyway
} else {
// This ensures application killed either by clearing recent or by anyother means
}