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
What is Intent? What is the difference between an implicit intent and an explicit intent?
How to add jar/library files as a dependency in Android studio gradle file
Check List for Generate Signed APK Android
ERROR Android emulator gets killed when I try to run my application and choose an emulator it ret
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
How to reduce APK package size?
How to convert DP to Pixel and Pixel to Dp?
ERR_ACCESS_DENIED in Android Webview with sdk 30
How do I check in SQLite whether a table exists?
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 ?
How do I generate random numbers in Dart?
What is Application?
What is the Different Between val and var in Kotlin?
How to extract date and time from Long type variable in Kotlin on Android "
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
What are Android Versions available?
How to get an image resource by it's name in android?
How to copy database from assets folder in android using kotlin
Android Activity FullScreen - How to set activity to fullscreen mode in Android?
Duplicate files during packaging of APK” build.gradle issue: Android Studio
Android FCM not receiving notifications when app is removed from background
How to install/ uninstall apk by command line ADB
How to Get bitmap from drawable: Android
What is Context?
How to get complete address from latitude and longitude?
What are the notifications available in android?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to convert milli seconds to hours, minutes and seconds in Android?
What is ANR? How to avoid and resolve it?
How to find Android Device UDID or unique ID?
How to save activity State in Android?
What is the difference between match_parent and fill_parent?
Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path
How to get screen size (width,height) in Android?
How To Set Text Color Programmatically Android TextView?
How to validate email address in Android with Kotlin?
What is Android?