Source:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); hasPreviouslyStarted = preferences.getBoolean(getString(R.string.preferences_has_previously_started), false); newUserButton = (Button) findViewById(R.id.newUserButtonFirstPage); newUserButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (hasPreviouslyStarted) { new AlertDialog.Builder(StartActivity.this) .setTitle("New Game") .setMessage("Wish to a start new game? All your saved progress might be lost.") .setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivityForResult(new Intent(StartActivity.this, AvatarRoomActivity.class), 0); } }) .setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }) .setIcon(alert_icon) .show(); } else { startActivityForResult(new Intent(StartActivity.this, AvatarRoomActivity.class), 0); } } }); startButton = (Button) findViewById(R.id.startButtonMain); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (hasPreviouslyStarted) { startActivity(new Intent(StartActivity.this, MapActivity.class)); } else { startActivity(new Intent(StartActivity.this, AvatarRoomActivity.class)); } } }); aboutButton = (Button) findViewById(R.id.aboutButtonMain); aboutButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(StartActivity.this, AboutActivity.class)); } }); }

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); hasPreviouslyStarted = preferences.getBoolean(getString(R.string.preferences_has_previously_started), false); newUserButton = (Button) findViewById(R.id.newUserButtonFirstPage); newUserButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (hasPreviouslyStarted) { new AlertDialog.Builder(StartActivity.this) .setTitle("New Game") .setMessage(getResources().getString(R.string.newGameWarning)) .setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivityForResult(new Intent(StartActivity.this, AvatarRoomActivity.class), 0); } }) .setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .setIcon(ResourcesCompat.getDrawable(getResources(),R.drawable.ic_launcher,null)) .show(); } else { startActivityForResult(new Intent(StartActivity.this, AvatarRoomActivity.class), 0); } } }); startButton = (Button) findViewById(R.id.startButtonMain); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (hasPreviouslyStarted) { startActivity(new Intent(StartActivity.this, MapActivity.class)); } else { startActivity(new Intent(StartActivity.this, AvatarRoomActivity.class)); } } }); aboutButton = (Button) findViewById(R.id.aboutButtonMain); aboutButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(StartActivity.this, AboutActivity.class)); } }); }