You should make your thread support interrupts. Basically, you can call yourThread.interrupt()
to stop the thread and, in your run() method you’d need to periodically check the status of Thread.interrupted()
There is a good tutorial here.
More Related Contents:
- SharedPreferences and Thread Safety
- Inflate a view in a background thread
- Latest available Android OS version for different devices [closed]
- Android studio 3.5 refactor issue
- Android: Want to set custom fonts for whole application not runtime
- overlay two images in android to set an imageview
- How to hide action bar before activity is created, and then show it again?
- ApiException: 9003: PLACES_API_ACCESS_NOT_CONFIGURED
- Android Broadcast Receiver bluetooth events catching
- PreferenceActivity Android 4.0 and earlier
- FCM with AWS SNS
- How to use Room Persistence Library with pre-populated database?
- Bulk Insertion on Android device
- how to capture an image in background without using the camera application
- RecyclerView steals focus when inside a NestedScrollView
- Cache.properties (The system cannot find the file specified)
- How to Enable Internal App Sharing for Android?
- How can I make my layout scroll both horizontally and vertically?
- How do I enable standard copy paste for a TextView in Android?
- Intent.putExtra List [duplicate]
- Android Webview gives net::ERR_CACHE_MISS message
- How to create a simple countdown timer in Kotlin?
- Backup/restore sqlite db in android [duplicate]
- How to get the file path from a URI that points to a PDF document?
- How to show a balloon above a marker in a MapActivity? Isn’t there a widget?
- WiFi Direct (Android 4.0) with multiple (3+) devices
- Android, how do I stop a pointer appearing below an EditText
- Can I draw outside the bounds of an Android Canvas
- Text color of a closed spinner
- Kotlin: open new Activity inside of a Fragment