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;
}
}
Open PDF in Google Drive with Intent in Android - RRutors
What is Context?
Add Jar/Library Files as Dependency in Android Studio
Decompile APK Files: How to Get Source Code - RRutors Guide
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
What is Android Fragments?
What are Android Versions available?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How to convert milli seconds to hours, minutes and seconds in Android?
How to get a contact image using a phone number in android?
Extract Date and Time from Long Type Variable - RRutors
How do I generate random numbers in Dart?
What is the difference between match_parent and fill_parent?
Fix Play Store Rejection Due to SMS Permission - RRutors
What is Intent? What is the difference between an implicit intent and an explicit intent?
Permission denied for window type 2010 in Marshmallow device
How to avoid multiple button click at same time in android?
Android Studio project R can't find
What is Android?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How do i load image from drawable folder in Jetpack Compose?
What happens next when the device switches between portrait and landscape?
What is Application?
How to install/ uninstall apk by command line ADB
How to get screen size (width,height) in Android?
How to get an image resource by it's name in android?
How to Exit android app on back pressed?
Check List for Generate Signed APK Android
How to reduce APK package size?
How to start a new activity on button click
How To Set Text Color Programmatically Android TextView?
How to copy database from assets folder in android using kotlin
What is NetworkOnMainThread Exception?
How to Generate signed apk with android studio
How do I check in SQLite whether a table exists?
How to find Android Device UDID or unique ID?
What is ANR? How to avoid and resolve it?
How can i comment inside xml file in android studio?
How to Use Deprecated Handler() in Android - RRutors Guide