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 Duplicate Files in APK Build.gradle Issue - RRutors
Add Jar/Library Files as Dependency in Android Studio
How to install/ uninstall apk by command line ADB
How to start a new activity on button click
How to avoid multiple button click at same time in android?
How can i comment inside xml file in android studio?
What are the notifications available in android?
Android Studio project R can't find
How to Exit android app on back pressed?
How to find Android Device UDID or unique ID?
How to stop EditText focus at Activity startup in Android?
Fix Android Emulator Kill Error When Running Your App
How to check Android version?
Open PDF in Google Drive with Intent in Android - RRutors
Permission denied for window type 2010 in Marshmallow device
What is "shared preferences" in Android ?
How to get complete address from latitude and longitude?
What is the difference between match_parent and fill_parent?
What is ANR? How to avoid and resolve it?
Fix Play Store Rejection Due to SMS Permission - RRutors
How to get an image resource by it's name in android?
Extract Date and Time from Long Type Variable - RRutors
Hide/Disable soft keyboard on Activity launch: Android
How to validate email address in Android with Kotlin?
How to save activity State in Android?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to copy database from assets folder in android using kotlin
How to get a contact image using a phone number in android?
How to convert milli seconds to hours, minutes and seconds in Android?
What is Application?
Key Points to remember while develop the Android Application.
What is Android Fragments?
How to reduce APK package size?
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
Explain Fragment Life Cycle
How do I generate random numbers in Dart?
FCM Not Receiving Notifications in Android - RRutors
What is Intent? What is the difference between an implicit intent and an explicit intent?
How to Get bitmap from drawable: Android
What is the Different Between val and var in Kotlin?