I am working on an application but I'm unable to understand savedInstanceState
properly when it occurs:
package com.android.Test;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class Test extends AppCompatActivity {
private TextView mTextView = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
Toast. makeText(getApplicationContext(),"welcome",Toast. LENGTH_SHORT).show();
} else {
Toast. makeText(getApplicationContext(),"Thanks visit again",Toast. LENGTH_SHORT).show();
}
}
}
how does the activity work when app closes and opens after a long time.
is there any other method for achieving this using savedInstanceState
or onRestoreInstanceState
.