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 get complete address from latitude and longitude?
How do I check in SQLite whether a table exists?
How to get screen size (width,height) in Android?
How To Set Text Color Programmatically Android TextView?
How to get a contact image using a phone number in android?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
What is Application?
Key Points to remember while develop the Android Application.
How to Exit android app on back pressed?
What is ANR? How to avoid and resolve it?
What is Android?
Decompile APK Files: How to Get Source Code - RRutors Guide
Fix Play Store Rejection Due to SMS Permission - RRutors
Fix Android Emulator Kill Error When Running Your App
Open PDF in Google Drive with Intent in Android - RRutors
How to save activity State in Android?
What is Context?
Invoke-customs are only supported starting with android 0 --min-api 26
How to convert DP to Pixel and Pixel to Dp?
Set Activity to Fullscreen Mode in Android - RRutors
What are the notifications available in android?
What is the Different Between val and var in Kotlin?
How to get an image resource by it's name in android?
How to copy database from assets folder in android using kotlin
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
Fix Duplicate Files in APK Build.gradle Issue - RRutors
ERR_ACCESS_DENIED in Android Webview with sdk 30
Add Jar/Library Files as Dependency in Android Studio
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
What is Intent? What is the difference between an implicit intent and an explicit intent?
How to avoid multiple button click at same time in android?
What is "shared preferences" in Android ?
Android Studio project R can't find
How do I generate random numbers in Dart?
How to find Android Device UDID or unique ID?
Check List for Generate Signed APK Android
What are Android Versions available?
How to start a new activity on button click
Extract Date and Time from Long Type Variable - RRutors
How to validate email address in Android with Kotlin?