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;
}
}
How to convert milli seconds to hours, minutes and seconds in Android?
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to check Android version?
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to install/ uninstall apk by command line ADB
How do i load image from drawable folder in Jetpack Compose?
How to get complete address from latitude and longitude?
ERROR Android emulator gets killed when I try to run my application and choose an emulator it ret
Hide/Disable soft keyboard on Activity launch: Android
Permission denied for window type 2010 in Marshmallow device
How do I generate random numbers in Dart?
How to add jar/library files as a dependency in Android studio gradle file
Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path
Is There A Way To Get The Source Code From An APK File? (or) How to decompile apk?
What is the difference between match_parent and fill_parent?
How to Generate signed apk with android studio
Android Studio project R can't find
What is Android?
How to convert DP to Pixel and Pixel to Dp?
How to copy database from assets folder in android using kotlin
Intent for Drive PDF Viewer - How to open PDF in Google Drive with intent
Could not inflate Behavior subclass android.support.design.widget. BottomSheetBehavior How resolve
What is Intent? What is the difference between an implicit intent and an explicit intent?
How can i comment inside xml file in android studio?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
Key Points to remember while develop the Android Application.
What are symmetric and asymmetric encryption in the way Android interacts with the server?
What is "shared preferences" in Android ?
What is NetworkOnMainThread Exception?
How to validate email address in Android with Kotlin?
How to stop EditText focus at Activity startup in Android?
Check List for Generate Signed APK Android
How To Set Text Color Programmatically Android TextView?
What is Android Fragments?
How to get a contact image using a phone number in android?
What is ANR? How to avoid and resolve it?
How to start a new activity on button click
How to Get bitmap from drawable: Android
Android FCM not receiving notifications when app is removed from background