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;
}
}
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
How to Generate signed apk with android studio
What is NetworkOnMainThread Exception?
How to copy database from assets folder in android using kotlin
What are Android Versions available?
Android Studio project R can't find
Check List for Generate Signed APK Android
How to save activity State in Android?
What is the Different Between val and var in Kotlin?
Explain Fragment Life Cycle
How to validate email address in Android with Kotlin?
What is the difference between match_parent and fill_parent?
How can i comment inside xml file in android studio?
How to get a contact image using a phone number in android?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How to install/ uninstall apk by command line ADB
Hide/Disable soft keyboard on Activity launch: Android
Invoke-customs are only supported starting with android 0 --min-api 26
How to get screen size (width,height) in Android?
How to start a new activity on button click
How to Get bitmap from drawable: Android
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
Open PDF in Google Drive with Intent in Android - RRutors
How to convert DP to Pixel and Pixel to Dp?
How to check Android version?
What is "shared preferences" in Android ?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
What are the notifications available in android?
How to get complete address from latitude and longitude?
FCM Not Receiving Notifications in Android - RRutors
How to reduce APK package size?
How to get an image resource by it's name in android?
What is Intent? What is the difference between an implicit intent and an explicit intent?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
Key Points to remember while develop the Android Application.
How to Use Deprecated Handler() in Android - RRutors Guide
What happens next when the device switches between portrait and landscape?
Fix Play Store Rejection Due to SMS Permission - RRutors
How to convert milli seconds to hours, minutes and seconds in Android?
ERR_ACCESS_DENIED in Android Webview with sdk 30