public void onBackPressed() {
   if (currentLayout == R.layout.snet_contact) {
     setLayoutMain();
     currentLayout = R.layout.snet_main;
   } else {
     super.onBackPressed();
   }
 }
  /**
   * Called whenever Android infrastructure feels like it; for example, if the user hits the Home
   * button.
   */
  @Override
  protected void onStop() {
    super.onStop();
    Log.d(TAG, "onStop");

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 3);
    SharedPreferences.Editor editor = settings.edit();
    editor.putInt("currentLayout", currentLayout);
    editor.commit();
  }
 /**
  * Called after we've been unloaded from memory and are restarting. E.g., 1st launch after
  * power-up; relaunch after going Home.
  */
 protected void onStart() {
   super.onStart();
   Log.d(TAG, "onStart");
   SharedPreferences settings = getSharedPreferences(PREFS_NAME, 3);
   if (settings.getInt("currentLayout", currentLayout) == R.layout.snet_main) {
     setLayoutMain();
     currentLayout = R.layout.snet_main;
   } else {
     Log.d(TAG, "Layout is contact");
     setLayoutContact();
     currentLayout = R.layout.snet_contact;
   }
   // save my context so that this app can retrieve it later
   ContextManager.setActivityContext(this);
 }
 /** Called when the activity is first created. */
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Log.d(TAG, "onCreate");
 }