Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

onSaveInstanceState() onRestoreInstanceState() basic Android example


public class MyClass extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       }
	 String sMyText = "some text";
	 int nMyInt = 10;

 @Override
 protected void onSaveInstanceState(Bundle outState) {
     // Save away the original text, so we still have it if the activity
     // needs to be killed while paused.
     outState.putString("my_text", sMyText);
     outState.putInt("my_int", nMyInt);
     Toast.makeText(this, "onSaveInstanceState()", Toast.LENGTH_LONG).show();
Log.i("onSaveInstanceState", "onSaveInstanceState()");
}
 String sNewMyText = "";
 int nNewMyInt = 0;
 
 @Override
 protected void onRestoreInstanceState(Bundle savedInstanceState) {
     super.onRestoreInstanceState(savedInstanceState);
     // restore saved values
     sNewMyText = savedInstanceState.getString("my_text");
     nNewMyInt = savedInstanceState.getInt("my_int");
     Toast.makeText(this, "onRestoreInstanceState()", Toast.LENGTH_LONG).show();
     Log.i("onRestoreInstanceState", "onRestoreInstanceState()");
     
 }
}

396LW NO topic_id




AD

Další témata ....(Topics)


21

How to install mount SD card for Eclipse Android Emulator | how-install-sd-card-on-android-eclipse-emulator


If you want download some *.apk file from internet and try on your emulator you get error than you have to install SD card. You have to closing Android emulator.
Mount Android emulator SD card instruction

  1. In Eclipse go in menu Window - Android SDK and Avg Manager

  2. Select Virtual devices

  3. Select AVD Name where you need install SD card

  4. Click on Edit button

  5. In open dialog go to SD card - Size: and write 500

  6. Press button Edit AVD

  7. Run AVD emulator


Image how install SD card on Android emulator in Eclipse.