What is the difference between (finish()) and (onBackPressed()) to end the activity Programmatically ???
I want to close the activity after a command (intent) Is it better to close it by command (finish) or using the command (onBackPressed)
Intent intent = new Intent ();
intent.putString("name", "Your Name");
setResult(RESULT_OK,intent);
onBackPressed();
or this better
Intent intent = new Intent ();
intent.putString("name", "Your Name");
setResult(RESULT_OK,intent);
finish();