Foreground Services - Android Basics 2023

  Переглядів 59,621

Philipp Lackner

Philipp Lackner

10 місяців тому

In this video you'll learn about services and foreground services on Android and how you can use them.
⭐ Learn all the professional technologies applied in the industry
⭐ 100% money back guarantee for 30 days
⭐ Become an industry-ready Android developer now:
pl-coding.com/premium-courses/
Get my FREE PDF about 20 things you should never do in Jetpack Compose:
pl-coding.com/jetpack-compose...
💻 Let me be your mentor and become an industry-ready Android developer in 10 weeks:
pl-coding.com/drop-table-ment...
Follow me on Instagram for insights into my live as an Android developer:
/ _philipplackner_
Subscribe to my FREE newsletter for regular Android, Kotlin & Architecture advice!
pl-coding.com/newsletter

КОМЕНТАРІ: 100
@leandro.developer
@leandro.developer 12 днів тому
im from brazil and i watch with subtitle ..Your channel is the best on UKposts on this subject...thank you.
@mahdiporkar236
@mahdiporkar236 7 місяців тому
Thanks for these great videos philipp!
@saeedghiassy5435
@saeedghiassy5435 10 місяців тому
Thank you! Great work like always :)
@denisk3852
@denisk3852 9 місяців тому
Amazing! Thank you bro ❤
@brianquigley1940
@brianquigley1940 15 днів тому
Sign of a great instructor: using past mistakes as learning opportunities ... 👍
@umidjonkosimov
@umidjonkosimov 10 місяців тому
First of all, I would like to thank you for making quality and easy to understand content, I got a question about notifications on android 12 and above. Why is it taking 5-7 seconds to show the notification for the first time? I am building a music player, and this is quite irritating. Thanks for the response
@sonnguyenphuc8142
@sonnguyenphuc8142 8 місяців тому
great video as usual!
@ivanvega9100
@ivanvega9100 10 місяців тому
Great video, really enjoyed it and learned from it!!
@markusknoch2266
@markusknoch2266 9 місяців тому
Hey Phil, that was a great introduction into ForegroundServices. However I would like to know how it’s possible to check if the service is running after the app has been closed? So I can block most of the UI and automatically start a ViewModel to monitor the ForegroundService
@SirDella
@SirDella 5 місяців тому
Holy F thank you, I didn't know you needed to add a channel from de app class, was looking at the android guides like crazy
@codein5
@codein5 6 місяців тому
Thank you that was an amazing video you have made!
@petrow_
@petrow_ 2 місяці тому
Thanks a lot, bro !
@AbdAtaya
@AbdAtaya 2 місяці тому
Fantastic, What a great explanation 🔥🔥
@brisammaresten2857
@brisammaresten2857 10 місяців тому
Hi Philipp, thanks for the great content. What I ask myself and already ran into when using services: Whats the best way for communication or interaction between service and viewmodel? As i know both should't know eachother. So do I need a class between and if so, the class would just pass the data through. Sounds unneccessary...
@psytoolkit
@psytoolkit 8 місяців тому
Thanks, that is very clear.
@tastatura993
@tastatura993 10 місяців тому
Thanks for the video. Can you say something regarding starting foreground service while the app is in the background? For Bluetooth apps do we need to use Companion Device Manager as mentioned in official documentation or is there some other way to start foreground service?
@wesjonm
@wesjonm 10 місяців тому
Amazing content as always!
@engineerOne
@engineerOne 10 місяців тому
I am actully enjoying and learning from this playlist And you content is ❤
@Jon776rus
@Jon776rus 10 місяців тому
These are very interesting videos, keep up the good work. Thank you very much
@onmoveonmove226
@onmoveonmove226 9 місяців тому
Thank you😊,what's a greet lesson
@Arcao
@Arcao 10 місяців тому
Note: Apps don't need to request the POST_NOTIFICATIONS permission in order to launch a foreground service. However, apps must include a notification when they start a foreground service, just as they do on previous versions of Android.
@PhilippLackner
@PhilippLackner 10 місяців тому
Yes you don't need it to launch one, but if your use case requires a foreground service, it's very likely it would be better UX to show a notification to the user
@aliciabeltran
@aliciabeltran 8 місяців тому
@@PhilippLackner spotify never send me a push notification to run the tracks on my device, I only see foreground task on the notification section, when I swipe down( left side)
@rodrigosoria5131
@rodrigosoria5131 6 місяців тому
But you need POST_NOTIFICATIONS to display the notification that must be included with the service, right? Because in such case then yes, it is needed, not directly, but it is. Or does the service work anyways?
@martinseal1987
@martinseal1987 10 місяців тому
Keep em coming
@shoprecartteam9567
@shoprecartteam9567 10 місяців тому
PLEASE, Make a video on modifying ripple effect, shape, and colors of buttons, iconbuttons and navigationbaritem. 🙏
@jorgericardorodriguezzapat427
@jorgericardorodriguezzapat427 9 місяців тому
Thanks for this cool well explained video. I need to implement this, but, I need the service to be launched when the phone boots, and I need to listen for incomming calls. Can I do that in this service ? I mean ... have a bradocastreceiver inside this service and launch this service when the phone just boot. Thanks !
@amrthapetmohamed3276
@amrthapetmohamed3276 3 місяці тому
Thanks for everything ❤❤❤❤❤
@ALEX54402
@ALEX54402 10 місяців тому
Thanks alot 🤩🤩
@MaxWeninger
@MaxWeninger 10 місяців тому
You should have mentioned the FGS TaskManager where you can also stop a service
@larrystreehouse1124
@larrystreehouse1124 10 місяців тому
Nice work. Just one question. how to deal with mutable flag/ immutable flag if my minimum sdk version is..24 ?
@chadisfeir3809
@chadisfeir3809 6 місяців тому
thank you for your tutorials !!! question: what is the service type for a vpn service ?
@olufemiezekiel7105
@olufemiezekiel7105 10 місяців тому
The link to the permissions tutorial wasn't added. I'm guessing you forgot as you predicted.😊. kindly point me to it. Thanks, Nice work.
@scotty3024
@scotty3024 10 місяців тому
What if we want to communicate with a service, get states inside it, etc.. only for a specific Jetpack Compose screen in our application and not for the whole activity that screen is in?
@HoveredCubeOfficial
@HoveredCubeOfficial 10 місяців тому
would u please make a short tutorial on how to enable and setup VPN mode in a kotlin app?
@vit4mint685
@vit4mint685 13 днів тому
I am curious how the interaction should be structured between a data layer, or if you can have start() in the service modify state variables to force recomposition? I suppose I am lost in the concepts for the architecture if wanting to tie in using a viewmodel.
@ShivaPrasad-hm5lk
@ShivaPrasad-hm5lk 9 місяців тому
Bro i need to track user location using geofencing in background so that when he leaves particular loaction another service should eb triggered and then another i kind of need them to get triggered in a chained reaction manner and all of this should be done in background even when the appi snot opened please tell em how to do thithis
@mubaraknative
@mubaraknative 5 місяців тому
I have a one doubt philipp uses Service class that run default on "main thread" when we perform some long-running operation our ui should freeze lead to "ANR" error, So instead of simple Service class we can use IntentService, or JobScheduler .
@vit4mint685
@vit4mint685 13 днів тому
This was a lot of help. I struggled for a little to figure out the changes needed to get API 34 requirements so the code would work. I am also a little confused on how I would go about updating notification. if wanting to implement a timer. My use case is trying to make a 'download bar', to indicate how far along I am in a download. I am still a little stuck, but this helped me quite a bit.
@m.sairam9607
@m.sairam9607 5 днів тому
Hey what changes did u make in code ?
@yamuuzz
@yamuuzz 10 місяців тому
Great videos!
@roshkaalex
@roshkaalex 10 місяців тому
Thank you. Good job! I have a question...I created restart function . I call stop and start service...and it's doesn't work as expected...why?)
@sumanth_g_l1120
@sumanth_g_l1120 8 місяців тому
Hi Bro, Why does Flutter not support foreground services for Android 11 and 12 ?
@mstntstt
@mstntstt 8 місяців тому
what different between thread and service ? .When do we use service in android ?
@veitklub
@veitklub 3 місяці тому
Notifications are delayed to reduce spam to the user for services that finish their work quickly. That's why your notification doesn't show right away. It started somewhere around API 30 or so and i think the delay is 5 or 10 seconds. You can get rid of this if you set your foregroundServiceType e.g. to phoneCall - a phoneCall should immediately show a notification, and so the notification is not delayed.
@shahbazansari52
@shahbazansari52 10 місяців тому
Hi Philip I watch your videos and it really helps me to learn new things and even crack interviews too. But only the thing is missing android security e.g SSL Pinning, Key Pinning & Hash Pinning there is no any good resource to learn from. Hope you will create an video soon with these topics. Thanks
@matteoZattera
@matteoZattera 10 місяців тому
Please make a video on how to save files locally and especially where to place the code to do that
@AleXoTroN
@AleXoTroN 7 місяців тому
Greetings from Hamburg, Germany! :)
@inspacesilence
@inspacesilence 5 місяців тому
please provide something for storage related task such as reading files, writing files etc.
@tamzidisrakadol1500
@tamzidisrakadol1500 14 днів тому
Please make a video about MediaSessionService.
@Dibyendu.M
@Dibyendu.M 9 місяців тому
My Problem: When the phone enters Doze mode, the foreground service stops working. How to prevent that?
@ahmedelbehiry1638
@ahmedelbehiry1638 5 місяців тому
Greate!
@onuremrekaradag7655
@onuremrekaradag7655 9 місяців тому
Hi Philip! First of all, thank you for this great playlist and the video. However, I didn't understand the last part you mentioned. From what I understand, you are suggesting not to place all of the code inside the Foreground Service, but rather keep it in other classes like ViewModels, etc. But If the app gets killed, all of these classes will be destroyed. I didn't quite grasp what you were trying to convey.
@VillagerYouTuber
@VillagerYouTuber 7 місяців тому
watch full video 21:00
@ahmedrashed2587
@ahmedrashed2587 10 місяців тому
Is there any available promo code for your courses ?
@teqanyteqany6350
@teqanyteqany6350 9 місяців тому
Great
@saeedsharif2463
@saeedsharif2463 9 місяців тому
dear where u made the startServices in my app not resolved
@mark-147
@mark-147 10 місяців тому
From the Activity, can't you call stopService() instead of startService() with STOP action?
@user-ni9xn8zn8u
@user-ni9xn8zn8u 3 місяці тому
please make video on api level 34 with service because foreground service crashes on api level 34 .
@4ytonly
@4ytonly 10 місяців тому
How about a music player foreground service?
@dolakrishnanseshachalam3028
@dolakrishnanseshachalam3028 7 місяців тому
Hi @4ytonly did you got Any solution for this?
@salman_salehXx
@salman_salehXx 10 місяців тому
Nice video just review the information
@Nick-cx4rs
@Nick-cx4rs 9 місяців тому
When not geting permission for android 13+ service is running in background without permission on me . Also already running correctly on +26 api devices without notificationChannel. Why we putting channels then ? How remove notification below android 13. Any trick ?
@muhannddh
@muhannddh 10 місяців тому
You didn't talk about how the Doze mode affect the services
@chndraja
@chndraja 10 місяців тому
Most of the OEM(Vivo, Xiomi,etc..) quit the service even if it is a foreground service with notification. do you have any idea how to handle this ??
@satnamsingh-qh2si
@satnamsingh-qh2si 12 днів тому
Give this man a shield 🛡️
@adnanansari4573
@adnanansari4573 8 днів тому
Can we start an activity automatically using foreground service, when app is in background in latest android?
@BiGprOtein65g
@BiGprOtein65g 6 місяців тому
can i WRITE My service class in kotlin but my other classes are in java?
@saeedsharif2463
@saeedsharif2463 9 місяців тому
dearr i am using the andirod 9 permision not got it
@thomasbartke
@thomasbartke 2 дні тому
This video has helped me a lot in adding foregroundService to my midi player app. Thanks! I still struggle with the notification behavior when the app is closed by the user. As you mentioned at the end of the video, the app remains fully functional and can be controlled through the notification. But when I relaunch the app it opens a second instance. Also, when I click anywhere on the notification while the app is still open, it directs me back to the app which is great, but when the app has been closed clicking on the notification (other than the designated action buttons) does not relaunch the app. Sorry for the long question but do you have a pointer on that issue?
@PhilippLackner
@PhilippLackner 2 дні тому
If you always want to open a specific page after clicking it, you need to make the pending intent trigger a deep link
@ujjwalgupta2890
@ujjwalgupta2890 4 місяці тому
hey Phil I have added all the permissions and services but in android 13 the service get's terminated after 3-4 minutes can you pleas provide some solutions how to fix this in android 13 In lower version of android foreground service run's forever until we intentionally kill that
@alix3665
@alix3665 2 місяці тому
12:55 philip u forgot to link the permission video❤
@anandnishad5730
@anandnishad5730 7 місяців тому
Git Link ??
@ArshamJafariGharibvand-bd6dj
@ArshamJafariGharibvand-bd6dj 10 місяців тому
What should we use, WorkManager or Services? and what are the benefits of them? I personally would like to use WorkManager because it support Coroutines What's your opinion?
@PhilippLackner
@PhilippLackner 10 місяців тому
Different use cases, watch the video 😄
@ArshamJafariGharibvand-bd6dj
@ArshamJafariGharibvand-bd6dj 10 місяців тому
@@PhilippLackner oh, better to make a short video about that😉
@igorkonyukhov497
@igorkonyukhov497 10 місяців тому
You can use coroutines inside the Service - why not?
@ArshamJafariGharibvand-bd6dj
@ArshamJafariGharibvand-bd6dj 10 місяців тому
@@igorkonyukhov497 Thank you❤️
@swiszcz93
@swiszcz93 10 місяців тому
you are an android god
@aboutthat9930
@aboutthat9930 10 місяців тому
Close!
@andreascollenberg
@andreascollenberg 6 місяців тому
True. If God would explain the world
@carlosmartinezsuarez3541
@carlosmartinezsuarez3541 3 місяці тому
I agree
@Titanus693
@Titanus693 17 днів тому
He is an Agi
@padmakargarg9720
@padmakargarg9720 5 місяців тому
XIaomi device does not dismiss lockscreen when opening Activity from background (VOIP Call) please help me out regarding this point
@LazypunK07
@LazypunK07 2 місяці тому
I recent use Xiaomi redmi note series but i throw it becoz of poor System opt. I am now back using OPPO and no regrets
@m.sairam9607
@m.sairam9607 5 днів тому
12:45 Permission video link- ukposts.info/have/v-deo/fGN7d6qYgm59tIk.htmlfeature=shared
@nagarajkatraj1711
@nagarajkatraj1711 Місяць тому
Now whom interesting to start the android journey . U are role like google map…
@ilhomsoliev275
@ilhomsoliev275 10 місяців тому
Fan fact: This is 666 th video on this channel
@Snoootz
@Snoootz 10 місяців тому
First
@LEGENDX22
@LEGENDX22 10 місяців тому
We love this series brooo make more video's ASAP 🫡
@garrysingh4484
@garrysingh4484 9 місяців тому
Goal : - Need to run a service in the background for 20-40 mins every 2 hour (Battery usage no issue) Correct me - if i m wrong : - WorkManagers workers thread has a hard limit of 10 minutes, which defeat the purpose of long running task in the background - I mean for short running repeated task its ok but for long running repeated task it doesn't work - As per my knowledge the best approach to run a long running repeated task is using foreground service - But some task doesn't need user interaction & some long running tasks doesn't need a foreground service ----> My question to you is what is the alternative ??? ----> To run the above task what options are available ???
@user-yx6fk5eo2h
@user-yx6fk5eo2h 8 місяців тому
ๅ🎉+=%%±66
@user-yx6fk5eo2h
@user-yx6fk5eo2h 8 місяців тому
😅😢😢😢😢😢😢😢😢😢😢😢😢
WorkManager - Android Basics 2023
34:22
Philipp Lackner
Переглядів 44 тис.
Піхотинці - про потребу у людях
00:57
Суспільне Новини
Переглядів 607 тис.
What is the Context? - Android Basics 2023
11:22
Philipp Lackner
Переглядів 45 тис.
Learnings from our multi-tenant Laravel application
9:58
Sabatino Masala
Переглядів 9 тис.
How to Implement a Shared Element Transition In Jetpack Compose
16:56
Philipp Lackner
Переглядів 8 тис.
Bound Services on Android
43:00
CodingWithMitch
Переглядів 61 тис.
I'm Coding for 13 Years to Find Out About THIS
2:04
Philipp Lackner
Переглядів 10 тис.
What's new in Python 3.13?
5:08
Carberra
Переглядів 13 тис.
Content Providers - Android Basics 2023
22:40
Philipp Lackner
Переглядів 30 тис.
SERVICES - Android Fundamentals
14:16
Philipp Lackner
Переглядів 48 тис.