The standard way to avoid multiple clicks is to save the last clicked time and avoid the other widget clicks within a preferred time private long lastPressesTime; @Override
Some times user may clicks multiple times on same widget, at that time App misleads and gives crassh/un expected behaviour to user.
We can resolve this by using the below code
public void onClick(View v) {
// Preventing multiple clicks, using threshold of 1 second
if (SystemClock.elapsedRealtime() - lastPressesTime < 1000) {
return;
}
lastPressesTime = SystemClock.elapsedRealtime();
switch(v.getId())
{
case R.id.widget1:
break;
case R.id.widget2:
break;
}
}
How to Exit android app on back pressed?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
FCM Not Receiving Notifications in Android - RRutors
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
How to convert milli seconds to hours, minutes and seconds in Android?
How do I generate random numbers in Dart?
How to convert DP to Pixel and Pixel to Dp?
Hide/Disable soft keyboard on Activity launch: Android
Decompile APK Files: How to Get Source Code - RRutors Guide
What are the notifications available in android?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
What is Intent? What is the difference between an implicit intent and an explicit intent?
What happens next when the device switches between portrait and landscape?
How can i comment inside xml file in android studio?
How to stop EditText focus at Activity startup in Android?
What is ANR? How to avoid and resolve it?
What is Application?
How to Get bitmap from drawable: Android
What is NetworkOnMainThread Exception?
How to start a new activity on button click
How to Use Deprecated Handler() in Android - RRutors Guide
How to find Android Device UDID or unique ID?
Open PDF in Google Drive with Intent in Android - RRutors
Permission denied for window type 2010 in Marshmallow device
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
How to reduce APK package size?
How to Generate signed apk with android studio
What is Android Fragments?
Key Points to remember while develop the Android Application.
How to get complete address from latitude and longitude?
How to avoid multiple button click at same time in android?
How to check Android version?
Android Studio project R can't find
How to install/ uninstall apk by command line ADB
What is Context?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
Add Jar/Library Files as Dependency in Android Studio
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
What is the Different Between val and var in Kotlin?
Explain Fragment Life Cycle