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 install/ uninstall apk by command line ADB
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
What is the Different Between val and var in Kotlin?
What happens next when the device switches between portrait and landscape?
How to convert DP to Pixel and Pixel to Dp?
How to start a new activity on button click
How to check Android version?
How can i comment inside xml file in android studio?
FCM Not Receiving Notifications in Android - RRutors
ERR_ACCESS_DENIED in Android Webview with sdk 30
What is Android Fragments?
Set Activity to Fullscreen Mode in Android - RRutors
Hide/Disable soft keyboard on Activity launch: Android
What is "shared preferences" in Android ?
How to get complete address from latitude and longitude?
What are Android Versions available?
Fix Android Emulator Kill Error When Running Your App
How to Use Deprecated Handler() in Android - RRutors Guide
How to copy database from assets folder in android using kotlin
What is the difference between match_parent and fill_parent?
Check List for Generate Signed APK Android
Permission denied for window type 2010 in Marshmallow device
How do i load image from drawable folder in Jetpack Compose?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
What is Android?
How to get a contact image using a phone number in android?
Explain Fragment Life Cycle
How to Exit android app on back pressed?
How to find Android Device UDID or unique ID?
How to convert milli seconds to hours, minutes and seconds in Android?
How do I check in SQLite whether a table exists?
How do I generate random numbers in Dart?
Decompile APK Files: How to Get Source Code - RRutors Guide
How to validate email address in Android with Kotlin?
Fix Play Store Rejection Due to SMS Permission - RRutors
How to reduce APK package size?
How to get screen size (width,height) in Android?
How to save activity State in Android?
What are the notifications available in android?