Darshak Darshak - 1 month ago 9
Android Question

How to resolve double tap on Button Issue in android?

Mockup of my Application :

Double Tap Mockup




Problem :

When click on button1 it just call Intent of ActivitySecond

button1.setOnClickListener(this);

public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId())
{
case R.id.button1:
Intent intent = new Intent(getApplicationContext(), ActivitySecond.class);
startActivity(intent);
break;
default:
break;
}
}


But, on Double tap it open twice ActivitySecond.




HOW TO RESOLVE IT.

PLEASE IF ANY SOLUTION THEN SHARE IT.

Thank you.

Answer Source

You can set launchMode of ActivitySecond to singleTop

<activity android:name=".ActivitySecond"
            android:launchMode="singleTop"
            >
            ...
</activity>