Basically you need to use Share-Preference
to achieve, put condition within onCreate that user checked initially or not
and call appropriate screen as per boolean. Try below code.
public class SplashScreen extends Activity {
SharedPreferences pref;
boolean state;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pref = getSharedPreferences("PackageName", Context.MODE_PRIVATE);
state= pref.getBoolean("State", false);
if(state){
Intent intent= new Intent(SplashScreen.this,NextActivity.class);
startActivity(intent);
finish();
}else{
setContentView(R.layout.fragment_main);
CheckBox chk = (CheckBox)findViewById(R.id.checkBox1);
Button btn =(Button)findViewById(R.id.button1);
chk.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
state=true;
}else{
state=false;
}
}
});
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Editor edit= pref.edit();
edit.putBoolean("State", state);
edit.commit();
Intent intent= new Intent(SplashScreen.this,NextActivity.class);
startActivity(intent);
}
});
}
}
}