I have an alert message that is in the main activity and that is executed at the moment of entering that activity, how can I make the alert message show once, that is, when it is for example in the activity 2 and return to the main activity the message will not be shown again
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Importante");
builder.setMessage("Recuerda activar el GPS para obtener tu ubicación");
builder.setPositiveButton("OK",null);
builder.create();
builder.show();
}