I am trying to prevent the activity from loading twice if I press the button twice instantly after the first click.
I have an activity which loads on click of a butt
You could just override startActivityForResult and use instance variable:
boolean couldStartActivity = false;
@Override
protected void onResume() {
super.onResume();
couldStartActivity = true;
}
@Override
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
if (couldStartActivity) {
couldStartActivity = false;
intent.putExtra(RequestCodeKey, requestCode);
super.startActivityForResult(intent, requestCode, options);
}
}