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;
}
}
Explain Fragment Life Cycle
How to Exit android app on back pressed?
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to convert DP to Pixel and Pixel to Dp?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
Decompile APK Files: How to Get Source Code - RRutors Guide
What is the difference between match_parent and fill_parent?
Check List for Generate Signed APK Android
How to Use Deprecated Handler() in Android - RRutors Guide
Android Studio project R can't find
Open PDF in Google Drive with Intent in Android - RRutors
How do I generate random numbers in Dart?
What is Intent? What is the difference between an implicit intent and an explicit intent?
How do i load image from drawable folder in Jetpack Compose?
Fix Play Store Rejection Due to SMS Permission - RRutors
What happens next when the device switches between portrait and landscape?
How do I check in SQLite whether a table exists?
What is Context?
What is ANR in android?
How to get screen size (width,height) in Android?
How to Generate signed apk with android studio
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to reduce APK package size?
How to stop EditText focus at Activity startup in Android?
How to find Android Device UDID or unique ID?
How to install/ uninstall apk by command line ADB
How to start a new activity on button click
Symmetric vs Asymmetric Encryption in Android Server - RRutors
Hide/Disable soft keyboard on Activity launch: Android
How to get an image resource by it's name in android?
How to avoid multiple button click at same time in android?
How to get a contact image using a phone number in android?
How to check Android version?
Key Points to remember while develop the Android Application.
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
How to save activity State in Android?
How To Set Text Color Programmatically Android TextView?
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
How to get complete address from latitude and longitude?
FCM Not Receiving Notifications in Android - RRutors