Showing posts with label Shared Preferences button back splash with android exam. Show all posts
Showing posts with label Shared Preferences button back splash with android exam. Show all posts

Wednesday, October 26, 2011

Shared Preferences button back splash with android exam

//Splash
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loading);
        app_preferences = PreferenceManager.getDefaultSharedPreferences(this);
        check = app_preferences.getInt("check", 1);
    }
//
protected void onResume() {
        // TODO Auto-generated method stub
        if(check==1){
            newTimerCounter(3);
        }else {
            finish();
        }
        super.onResume();
    }
//Activity Main
public boolean onKeyDown(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub
         if ((keyCode == KeyEvent.KEYCODE_BACK)) {
             SplashActivity.check = 0;
             Log.d(this.getClass().getName(), "back button pressed");
            }
            return super.onKeyDown(keyCode, event);

    }