- From your activity, call
startService(intent)
and pass it some data representing a key to stop the service. - From your service, call
stopForeground(true)
- and then
stopSelf()
right after it.
More Related Contents:
- Background Services are restricted in Xiaomi and Oppo
- How To Start An Activity From Background in Android 10?
- Comparison of Android networking libraries: OkHTTP, Retrofit, and Volley [closed]
- Check INTENT internet connection
- TelephonyManager.getLine1Number() failing?
- Android: Force EditText to remove focus? [duplicate]
- Common class for AsyncTask in Android?
- How can I make sticky headers in RecyclerView? (Without external lib)
- support FragmentPagerAdapter holds reference to old fragments
- Set Limit on the DatePickerDialog in Android?
- How to compress image size?
- Android MediaPlayer Stop and Play
- How to create a drop-down list?
- What kind of font files do I need for modern browsers, Android and IOS?
- How to disable displaying “suggestions” on the Soft Keyboard
- Scroll webview horizontally inside a ViewPager
- How can I filter ListView data when typing on EditText in android
- Drawable tinting for api
- handling links in a webview
- How to setContentView in a fragment?
- Relocate Google logo in MapView
- How to restart ADB manually from Android Studio
- Accessing files from genymotion sd card
- Android SDK Manager gives “Failed to fetch URL https://dl-ssl.google.com/android/repository/repository.xml” error when selecting repository
- Start Google Hangout from Intent in New Hangouts Android app
- Auto-Update for (private) Android apps
- org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused in android
- I get this error: Data exceeds UNCOMPRESS_DATA_MAX on android 2.2 but not on 2.3
- Android webview loadDataWithBaseURL how load images from assets?
- Android: Checking network connectivity return not connected when connected to wifi/3g in Broadcast receiver