-2

I'm try too restore string value, when screen is rotate, but it's always null.

public class Main_screen extends Activity {
    TextView t;
    String path, ext;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main_screen);
        t = (TextView) findViewById(R.id.textView2);
        if (savedInstanceState != null){
            path = savedInstanceState.getString(path);
            ext = savedInstanceState.getString(ext);
            t.setText(getString(R.string.selected) + "\n" + path + "\n\n" + getString(R.string.unpr_new) + "\n" + path + ext);
        }
    }

When I rotate device, path and ext is null. Need I save string manualy? Or it's saved automatic when rotate in savedinstance?

1 Answers1

2

check this if in the Manifest file you declaring

android:configChanges="orientation"

if you declared this flag, the activity will not be destroyed and recreated and the callback

and override this method :==>> onConfigurationChanged()

will be called.

Mehul Ranpara
  • 4,245
  • 2
  • 26
  • 39