This shows you the differences between two versions of the page.
smd:laboratoare:03 [2021/04/01 16:41] adriana.draghici |
smd:laboratoare:03 [2021/04/08 16:57] (current) adriana.draghici [Using Intent Services] |
||
---|---|---|---|
Line 83: | Line 83: | ||
====Start a service==== | ====Start a service==== | ||
+ | |||
<code java> | <code java> | ||
Line 113: | Line 114: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | :!: If your project is configured for versions higher than Oreo, there's no need to perform the check for Oreo. | ||
+ | |||
====Start foreground service==== | ====Start foreground service==== | ||
- | * Create a persistent notification (see [[https://proandroiddev.com/deep-dive-into-android-services-4830b8c9a09|example]]) | + | * Examples: [[https://developer.android.com/guide/components/foreground-services#java|documentation]], [[https://androidwave.com/foreground-service-android-example/|tutorial]] |
+ | * Create a persistent notification like in the links provided above. | ||
* Call ''startForeground'' | * Call ''startForeground'' | ||
Line 223: | Line 228: | ||
* If we want to send a response from the IntentService to the activity, we can broadcast the result using intents and register a broadcast receiver for them. | * If we want to send a response from the IntentService to the activity, we can broadcast the result using intents and register a broadcast receiver for them. | ||
+ | |||
+ | /* | ||
+ | TODO INTENT SERVICE IS DEPRECATED, LEAVE THE TEXT< ADD A WARNING AND REMOVE THE EXERCISE | ||
+ | */ | ||
=== Task 3 LuckyIntentService (2p) === | === Task 3 LuckyIntentService (2p) === | ||