Foreground Services - Android Basics 2023

  Рет қаралды 89,053

Philipp Lackner

Philipp Lackner

Күн бұрын

Пікірлер: 134
@leandro.developer
@leandro.developer 7 ай бұрын
im from brazil and i watch with subtitle ..Your channel is the best on KZbin on this subject...thank you.
@Arcao
@Arcao Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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)
@rosodev
@rosodev Жыл бұрын
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?
@supernova.09
@supernova.09 2 ай бұрын
For API 34, the service in the manifest needs to be and add permission Hope this helps someone!
@anshbajaj7223
@anshbajaj7223 2 ай бұрын
thank you sooo muchhh!!
@veitklub
@veitklub 11 ай бұрын
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.
@umidjonkosimov
@umidjonkosimov Жыл бұрын
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
@嘿嘿嘿-z1v
@嘿嘿嘿-z1v 5 ай бұрын
I'm handling foregroundServiceType while migrating to Android 14 recently. Thanks for the clear explaination :)
@saber1981mm
@saber1981mm 4 ай бұрын
Im from Egypt ..Your channel is the best on KZbin on this subject...thank you. 😍😍
@alibasha50
@alibasha50 13 күн бұрын
أزيك ياصاحبي،،
@amresmail729
@amresmail729 3 күн бұрын
Egypt is a very beautiful country with good people and I would like to come and visit it....Your brother from Mansoura
@jorgericardorodriguezzapat427
@jorgericardorodriguezzapat427 Жыл бұрын
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 !
@vit4mint685
@vit4mint685 8 ай бұрын
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.
@Darkwolf9280
@Darkwolf9280 7 ай бұрын
Hey what changes did u make in code ?
@shoprecartteam9567
@shoprecartteam9567 Жыл бұрын
PLEASE, Make a video on modifying ripple effect, shape, and colors of buttons, iconbuttons and navigationbaritem. 🙏
@ufukozturk5312
@ufukozturk5312 6 ай бұрын
You just saved my whole life thx!!
@AleXoTroN
@AleXoTroN Жыл бұрын
Greetings from Hamburg, Germany! :)
@markusknoch2266
@markusknoch2266 Жыл бұрын
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
@onmoveonmove226
@onmoveonmove226 Жыл бұрын
Thank you😊,what's a greet lesson
@garrysingh4484
@garrysingh4484 Жыл бұрын
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 ???
@เบญจมาศสีน้ําอ้อม-บ8ภ
@เบญจมาศสีน้ําอ้อม-บ8ภ Жыл бұрын
ๅ🎉+=%%±66
@เบญจมาศสีน้ําอ้อม-บ8ภ
@เบญจมาศสีน้ําอ้อม-บ8ภ Жыл бұрын
😅😢😢😢😢😢😢😢😢😢😢😢😢
@onuremrekaradag
@onuremrekaradag Жыл бұрын
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 Жыл бұрын
watch full video 21:00
@2chotti
@2chotti 25 күн бұрын
Thank you
@Jon776rus
@Jon776rus Жыл бұрын
These are very interesting videos, keep up the good work. Thank you very much
@AbdAtaya
@AbdAtaya 9 ай бұрын
Fantastic, What a great explanation 🔥🔥
@psytoolkit
@psytoolkit Жыл бұрын
Thanks, that is very clear.
@codein5
@codein5 Жыл бұрын
Thank you that was an amazing video you have made!
@engineerOne
@engineerOne Жыл бұрын
I am actully enjoying and learning from this playlist And you content is ❤
@olufemiezekiel7105
@olufemiezekiel7105 Жыл бұрын
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.
@ALEX54402
@ALEX54402 Жыл бұрын
Thanks alot 🤩🤩
@swiszcz93
@swiszcz93 Жыл бұрын
you are an android god
@aboutthat9930
@aboutthat9930 Жыл бұрын
Close!
@andreascollenberg
@andreascollenberg Жыл бұрын
True. If God would explain the world
@carlosmartinezsuarez3541
@carlosmartinezsuarez3541 11 ай бұрын
I agree
@AttackTitan008
@AttackTitan008 8 ай бұрын
He is an Agi
@amrthapetmohamed3276
@amrthapetmohamed3276 11 ай бұрын
Thanks for everything ❤❤❤❤❤
@LEGENDX22
@LEGENDX22 Жыл бұрын
We love this series brooo make more video's ASAP 🫡
@sonnguyenphuc8142
@sonnguyenphuc8142 Жыл бұрын
great video as usual!
@ivanvega9100
@ivanvega9100 Жыл бұрын
Great video, really enjoyed it and learned from it!!
@spyro2008
@spyro2008 6 ай бұрын
Thank you a lot!❤️
@mahdiporkar236
@mahdiporkar236 Жыл бұрын
Thanks for these great videos philipp!
@wesjonm
@wesjonm Жыл бұрын
Amazing content as always!
@mubaraknative
@mubaraknative Жыл бұрын
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 .
@SirDella
@SirDella Жыл бұрын
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
@saeedghiassy5435
@saeedghiassy5435 Жыл бұрын
Thank you! Great work like always :)
@denisk3852
@denisk3852 Жыл бұрын
Amazing! Thank you bro ❤
@satnamsingh-qh2si
@satnamsingh-qh2si 7 ай бұрын
Give this man a shield 🛡️
@muhammadanugrahhakiki2997
@muhammadanugrahhakiki2997 4 ай бұрын
Thank you !
@MaxWeninger
@MaxWeninger Жыл бұрын
You should have mentioned the FGS TaskManager where you can also stop a service
@yamuuzz
@yamuuzz Жыл бұрын
Great videos!
@shahbazansari52
@shahbazansari52 Жыл бұрын
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
@4ytonly
@4ytonly Жыл бұрын
How about a music player foreground service?
@dolakrishnanseshachalam3028
@dolakrishnanseshachalam3028 Жыл бұрын
Hi @4ytonly did you got Any solution for this?
@vit4mint685
@vit4mint685 7 ай бұрын
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.
@ArshamJafariGharibvand-bd6dj
@ArshamJafariGharibvand-bd6dj Жыл бұрын
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 Жыл бұрын
Different use cases, watch the video 😄
@ArshamJafariGharibvand-bd6dj
@ArshamJafariGharibvand-bd6dj Жыл бұрын
@@PhilippLackner oh, better to make a short video about that😉
@igorkonyukhov497
@igorkonyukhov497 Жыл бұрын
You can use coroutines inside the Service - why not?
@ArshamJafariGharibvand-bd6dj
@ArshamJafariGharibvand-bd6dj Жыл бұрын
@@igorkonyukhov497 Thank you❤️
@tastatura993
@tastatura993 Жыл бұрын
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?
@Vladimir1977K
@Vladimir1977K Ай бұрын
if you rotate the phone screen, then updating coordinates in the service becomes very frequent. The specified interval does not solve the problem. And, if you send these coordinates to the server, then the traffic volume and battery consumption are very high
@Pavel-wj7gy
@Pavel-wj7gy 5 ай бұрын
19:38 - I am wondering if the process was actually destroyed, because if you try log some values in Logcat, you will see that there's no --- PROCESS ENDED (19429) --- message when you stop the service. The app looks like it still runs in the background which might be bad in terms of potential memory leaks.
@PhilippLackner
@PhilippLackner 5 ай бұрын
The process stays alive, just the activity is destroyed. That's intended
@HoveredCubeOfficial
@HoveredCubeOfficial Жыл бұрын
would u please make a short tutorial on how to enable and setup VPN mode in a kotlin app?
@petrow_
@petrow_ 10 ай бұрын
Thanks a lot, bro !
@salman_salehXx
@salman_salehXx Жыл бұрын
Nice video just review the information
@brisammaresten2857
@brisammaresten2857 Жыл бұрын
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...
@abdelrhmanghanem6661
@abdelrhmanghanem6661 Ай бұрын
I have a question about bound service can it be replaced with coroutine ? I hope you make an example about it
@roshkaalex
@roshkaalex Жыл бұрын
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?)
@ShivaPrasad-hm5lk
@ShivaPrasad-hm5lk Жыл бұрын
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
@martinseal1987
@martinseal1987 Жыл бұрын
Keep em coming
@saeedsharif2463
@saeedsharif2463 Жыл бұрын
dear where u made the startServices in my app not resolved
@mstntstt
@mstntstt Жыл бұрын
what different between thread and service ? .When do we use service in android ?
@tamzidisrakadol1500
@tamzidisrakadol1500 8 ай бұрын
Please make a video about MediaSessionService.
@chadisfeir3809
@chadisfeir3809 Жыл бұрын
thank you for your tutorials !!! question: what is the service type for a vpn service ?
@mark-147
@mark-147 Жыл бұрын
From the Activity, can't you call stopService() instead of startService() with STOP action?
@scotty3024
@scotty3024 Жыл бұрын
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?
@matteoZattera
@matteoZattera Жыл бұрын
Please make a video on how to save files locally and especially where to place the code to do that
@larrystreehouse1124
@larrystreehouse1124 Жыл бұрын
Nice work. Just one question. how to deal with mutable flag/ immutable flag if my minimum sdk version is..24 ?
@АртурШитиков-ь2ъ
@АртурШитиков-ь2ъ 4 ай бұрын
Hey, I wanted to know why it's better to use foreground services for the same music player? Why not just use Work Manager, which also has setForeground and seems to do the same thing?
@easybusinessou
@easybusinessou Жыл бұрын
Great
@sumanth_g_l1120
@sumanth_g_l1120 Жыл бұрын
Hi Bro, Why does Flutter not support foreground services for Android 11 and 12 ?
@ahmedrashed2587
@ahmedrashed2587 Жыл бұрын
Is there any available promo code for your courses ?
@Nick-cx4rs
@Nick-cx4rs Жыл бұрын
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 ?
@saeedsharif2463
@saeedsharif2463 Жыл бұрын
dearr i am using the andirod 9 permision not got it
@alix3665
@alix3665 9 ай бұрын
12:55 philip u forgot to link the permission video❤
@chndraja
@chndraja Жыл бұрын
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 ??
@eddyGaming007
@eddyGaming007 7 ай бұрын
Can we start an activity automatically using foreground service, when app is in background in latest android?
@inspacesilence
@inspacesilence Жыл бұрын
please provide something for storage related task such as reading files, writing files etc.
@MuhammadArsalan-c1w
@MuhammadArsalan-c1w 11 ай бұрын
please make video on api level 34 with service because foreground service crashes on api level 34 .
@thomasbartke
@thomasbartke 7 ай бұрын
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 7 ай бұрын
If you always want to open a specific page after clicking it, you need to make the pending intent trigger a deep link
@muhannddh
@muhannddh Жыл бұрын
You didn't talk about how the Doze mode affect the services
@Dibyendu.M
@Dibyendu.M Жыл бұрын
My Problem: When the phone enters Doze mode, the foreground service stops working. How to prevent that?
@luciferkind9211
@luciferkind9211 3 ай бұрын
you save me! you are god!
@santanusur1265
@santanusur1265 Ай бұрын
Does the foreground service stop , when we kill the app ? Or do we need to handle it by ourselves. ( For eg :- when we kill spotify , the music stops playing in the background - is it handled by the OS itself or its a dev task )
@PhilippLackner
@PhilippLackner Ай бұрын
If the process is killed, all of it dies. However, just "killing" the app by swiping it from the recently used apps will keep the process alive if there's a foreground service active. Activities and ViewModels might die though.
@ahmedelbehiry1638
@ahmedelbehiry1638 Жыл бұрын
Greate!
@david_whyte
@david_whyte 5 ай бұрын
Hi I need to run an app as a server, it needs to be a TCP based server. I have built the server with kotlin, it runs with foreground service. It works fine, I send messages via the phone IP. Can this app run in foreground forever? The idea is to have the phone on at all times. and it should basically act as a server
@padmakargarg9720
@padmakargarg9720 Жыл бұрын
XIaomi device does not dismiss lockscreen when opening Activity from background (VOIP Call) please help me out regarding this point
@LazypunK07
@LazypunK07 10 ай бұрын
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
@Mylove260690
@Mylove260690 5 ай бұрын
Please can you suggest how we can make service without activity with boot reciever
@BiGprOtein65g
@BiGprOtein65g Жыл бұрын
can i WRITE My service class in kotlin but my other classes are in java?
@ruhilkitchen8880
@ruhilkitchen8880 4 ай бұрын
Why my foreground service stope in the night like given latitude or longitude with gap bt when I used device thn continuously running
@ujjwalgupta2890
@ujjwalgupta2890 11 ай бұрын
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
@ahmadharb9677
@ahmadharb9677 4 ай бұрын
You should have mentioned the did not start in time exception that will be thrown if startForeground was not called in 5 seconds after starting the service and the crash that you will have if you pressed the stop service button before the appearance of the service notification. It’s the worst thing made in android
@ephraimumunnakwe4632
@ephraimumunnakwe4632 Ай бұрын
This means we'd have to disable the stop button unless it's already running, problem solve init?
@davidsosa5940
@davidsosa5940 4 ай бұрын
How can i show a push notification when my app is on the foreground?
@unlimitedparody1482
@unlimitedparody1482 Ай бұрын
Can you show me detail of MainActivity code. You didnt show the entire code. Please
@brianquigley1940
@brianquigley1940 8 ай бұрын
Sign of a great instructor: using past mistakes as learning opportunities ... 👍
@entertaiNmotivate
@entertaiNmotivate 2 ай бұрын
you didnt add permissions in android basics playlist
@shalenmathew
@shalenmathew 2 ай бұрын
Link of the Permisson Handling he mentioned in his video kzbin.info/www/bejne/emStdKeXgJ1_ibcsi=w9D6ZNeGpfsnSJ6X
@anandnishad5730
@anandnishad5730 Жыл бұрын
Git Link ??
@nagarajkatraj1711
@nagarajkatraj1711 9 ай бұрын
Now whom interesting to start the android journey . U are role like google map…
@ilhomsoliev275
@ilhomsoliev275 Жыл бұрын
Fan fact: This is 666 th video on this channel
@ruhilkitchen8880
@ruhilkitchen8880 4 ай бұрын
Hy I’m facing one issue from many times
@Darkwolf9280
@Darkwolf9280 7 ай бұрын
12:45 Permission video link- kzbin.info/www/bejne/emStdKeXgJ1_ibcfeature=shared
@Snoootz
@Snoootz Жыл бұрын
First
@conscienciasublateral6496
@conscienciasublateral6496 5 ай бұрын
@conscienciasublateral6496
@conscienciasublateral6496 5 ай бұрын
I'm From BRA
WorkManager - Android Basics 2023
34:22
Philipp Lackner
Рет қаралды 63 М.
ViewModels & Configuration Changes - Android Basics 2023
18:46
Philipp Lackner
Рет қаралды 136 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
Awesome Frontend Libraries and AI
35:28
Know It Today
Рет қаралды 84
95% Don't Understand THIS About Coroutines (Main-Safety)
9:38
Philipp Lackner
Рет қаралды 31 М.
Google’s Quantum Chip: Did We Just Tap Into Parallel Universes?
9:34
Intents & Intent Filters - Android Basics 2023
25:36
Philipp Lackner
Рет қаралды 83 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН