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 reduce APK package size?
What is ANR in android?
What are symmetric and asymmetric encryption in the way Android interacts with the server?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to start a new activity on button click
Duplicate files during packaging of APK” build.gradle issue: Android Studio
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
What is NetworkOnMainThread Exception?
What is Context?
What is "shared preferences" in Android ?
How to extract date and time from Long type variable in Kotlin on Android "
Android FCM not receiving notifications when app is removed from background
How to convert DP to Pixel and Pixel to Dp?
How to stop EditText focus at Activity startup in Android?
What is ANR? How to avoid and resolve it?
How do I check in SQLite whether a table exists?
How to Get bitmap from drawable: Android
How to avoid multiple button click at same time in android?
What is Android?
How to get a contact image using a phone number in android?
What is Application?
How To Set Text Color Programmatically Android TextView?
Is There A Way To Get The Source Code From An APK File? (or) How to decompile apk?
How to check Android version?
How to Exit android app on back pressed?
Hide/Disable soft keyboard on Activity launch: Android
How to get screen size (width,height) in Android?
What are Android Versions available?
How do I generate random numbers in Dart?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
How can i comment inside xml file in android studio?
What is Intent? What is the difference between an implicit intent and an explicit intent?
Android Activity FullScreen - How to set activity to fullscreen mode in Android?
What are the notifications available in android?
Invoke-customs are only supported starting with android 0 --min-api 26
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to add jar/library files as a dependency in Android studio gradle file
What is the Different Between val and var in Kotlin?
How to copy database from assets folder in android using kotlin