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;
}
}
Add Jar/Library Files as Dependency in Android Studio
How to convert milli seconds to hours, minutes and seconds in Android?
Invoke-customs are only supported starting with android 0 --min-api 26
What is Intent? What is the difference between an implicit intent and an explicit intent?
How to save activity State in Android?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
What are Android Versions available?
How to find Android Device UDID or unique ID?
How to Get bitmap from drawable: Android
Explain Fragment Life Cycle
How to validate email address in Android with Kotlin?
Permission denied for window type 2010 in Marshmallow device
What happens next when the device switches between portrait and landscape?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
How to Use Deprecated Handler() in Android - RRutors Guide
Fix Android Emulator Kill Error When Running Your App
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
How do i load image from drawable folder in Jetpack Compose?
How do I check in SQLite whether a table exists?
Extract Date and Time from Long Type Variable - RRutors
How to get complete address from latitude and longitude?
Decompile APK Files: How to Get Source Code - RRutors Guide
How to convert DP to Pixel and Pixel to Dp?
What is ANR in android?
What is NetworkOnMainThread Exception?
How to reduce APK package size?
What is Android?
Set Activity to Fullscreen Mode in Android - RRutors
How to avoid multiple button click at same time in android?
What is Android Fragments?
Fix Play Store Rejection Due to SMS Permission - RRutors
Android Studio project R can't find
What is ANR? How to avoid and resolve it?
Key Points to remember while develop the Android Application.
What is Application?
How to Generate signed apk with android studio
How to copy database from assets folder in android using kotlin
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
How to start a new activity on button click