2017-06-02 9 views
0

3つのページ、ログイン、スプラッシュ、MainActivityがあるので、ユーザーがログインしていない場合は、スプラッシュの後にログインページを上げる必要があります。 Realm Databaseフィールドがいっぱいになっていて、それがある場合、ユーザーが既にログに記録されていることを意味しますが、そうでない場合、ログインページが表示され、正常に動作しますが、彼がAppに復帰したときにどのようにこれを処理するか、Configurationsのデータを消去しますか?それはOnPauseにありますか?ユーザーがデータを消去するのを避ける他の方法はありますか?androidを使用してlaucherを処理する方法

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

答えて

0
It is better save the data 

共有優先して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 
} 
関連する問題