I was working on a ble sensor client service which must communicate consistently with an activity and I was almost hopeless because of the android os restrictions and started service logic. You are solving a very complex issue about android services with a such simple example :) thanks
@codingwithmitch6 жыл бұрын
******************** WARNING: BUG ************************ Thanks to @Pemba Tamang for finding this bug. Inside the "run" method of the runnable inside MainActivity, change the "aBoolean" variable to "mViewModel.getIsProgressUpdating().getValue()". If you don't do this then the runnable will continue running forever and spawning new instances. It's due to the "aBoolean" variable being final and then being used to control whether the runnable runs or not. If it's final, it will never change. So obviously the runnable will continue running forever. Here is a gist with the updated run method: gist.github.com/mitchtabian/0621da267a677cabcd1f270e3c6513fa
@pembatamang82336 жыл бұрын
its Tamang
@TechMalaya5 жыл бұрын
I love ur tutorial when u explain it very simple to understand for me. Keep it going mitch. I just stuck using bound service in mvvm and u the only reference that I had.
@atifmbhutta5 жыл бұрын
Damnn Mitch you are the best. Precise and to the point. Very well explained videos always.
@trollrar5 жыл бұрын
Background thread service tutorial please :)
@hassanruben10193 жыл бұрын
Instablaster...
@muneerhasan4 жыл бұрын
This video about service is best video on services. This video cleared my all doubt 💯💯. Thanks a lot Mitch
@bjugdbjk6 жыл бұрын
Fabulous explanation, Thank you so much, Appreciate your efforts.
@Since10594 жыл бұрын
Really Really Really so nice and clean directions about bind services 😘😘😘😘
@kunalsahu43 жыл бұрын
Thank you so much Mitch, that very cool explanation. I request you to please create more content on Services and running task in BG
@AnkurJagani10005 жыл бұрын
That will be great if you can make video on startForegroundServices which is must for Android O devices.
@maheswaranmohan5425 жыл бұрын
Please make a video to cover all points including started service, foreground service, Run service in background thread.....and android O..... And how to choose the correct one....
@АлексейРодионов-ы8о2 жыл бұрын
The best tutorial on services I ever seen
@satyamsharma82403 жыл бұрын
Love the way you made everything so simple
@amremam89374 жыл бұрын
I would be great if you have added an example of aidl in this video
@developerkang37173 жыл бұрын
this is exactly What i neeed!! Thank you from South korea
@ChrisAthanas4 жыл бұрын
Some engagement getting you to 100k
@Priyanshu-nq8rm Жыл бұрын
Thanks Mitch for an awesome tutorial ☺️
@ankitrajdwivedi9966 жыл бұрын
Yes we need video on background thread
@codingwithmitch6 жыл бұрын
noted
@jinothomas83654 жыл бұрын
@@codingwithmitch link?
@virus20283 жыл бұрын
Good work, thanx for the lecture man. Helped a lot
@alirzayucefaydal5916 жыл бұрын
my mind blown :D i believe we need to go deeper and do more exercises with ur help :D
@mirkaram5485 жыл бұрын
Make video on Starting service in ANDROID.O and changes in O. Your explanation is amazing with architectural design.
@devanshu_on_youtube2 жыл бұрын
Hey Mitch, love your tutorials! But if I may, isn't viewing a bound/started as service types (though not mutually exclusive) a bit inaccurate as a mental model? What exists is the Service class by itself - it can either be started, be started and bound to or be started as a consequence of being bound to. I think the folks have revised the documentation to reflect this representation as well.
@nandandesai65246 жыл бұрын
How can you run a service in a background thread? Please please make a video on it. Thanks!
@TheMikkelet3 жыл бұрын
I do not understand this example, Mitch. I tried downloading the repo and run it. The app doesnt maintain state. There's no notification, like you'd see in a media app, and the app resets the timer if you swipe to close. What is the point of a service exactly? Because it doesn't seem to hold any persistent state
@amitabhsarkar95715 жыл бұрын
Please make a tutorial of forgroundService for android O.
@dineshchoudhary82216 жыл бұрын
Yes please do a video on running services in a background thread
@codingwithmitch6 жыл бұрын
noted
@realtimeexperience44704 жыл бұрын
your all videos are awesome. Can you make a complete video/split in series which has all the folder structure.. where to keep UI/ViewModel/Data/DB/Network with MVVM best practice.
@capitalcouch50956 жыл бұрын
Hey Mitch, Great Stuff. Your content has helped me a lot in learning Android. I am starting to do videos on Android as well. I was checking your older videos, a huge improvement in video quality over time. What kind of screen recording software are you using? Thanks :)
@codingwithmitch6 жыл бұрын
Hey, it's camtasia.
@codingwithmitch6 жыл бұрын
What kind of videos will you be making? Like what topics?
@capitalcouch50956 жыл бұрын
I will start with general beginners Android topics. It seems these get the most views, to get the attraction. Eventually, stuff like building clone apps, or in-depth on a certain topic. You have some recommendation?
@codingwithmitch6 жыл бұрын
@@capitalcouch5095 if you are looking to maximize attention then definitely beginner stuff. The unfortunate thing about that is it gets very boring lol
@capitalcouch50956 жыл бұрын
Haha, well no pain no subs gain. Actually, I haven't seen many videos on beginners stuff but digging down in the implementation details inside android framework. What can we expect on this channel for the next year?
@szymek16s Жыл бұрын
Great tutorial, I looking for solution of my problem and it's hard. I have an app which counting work time but when user closed app by accident I want that my time will be still counting cous of the service and whats happend that viewmodel updating view all the time in the same time ForegroundService do the same and my timer shows wrong value.
@guillermoperez82504 жыл бұрын
Cool stuff, thank you. You can get a reference to the service as soon as you bind to it, no need for the observer. Just do: MyService.LocalBinder binder = (MyService.LocalBinder) service; mService = binder.getService();
@ryszardmachmudow91753 жыл бұрын
I read ViewModel should not contain services, because Service has it's own lifecycle. Service field will lead to context leak.
@nodajifi4 жыл бұрын
Great leacture about service. In a bound service, I want to implement the never-ending sevice after booting the smartphone. I know that case in a started service but I don't have any clues in the bound one. Could you give me some comments?
@shawngardner2613 жыл бұрын
I enjoy your tutorials and classes. Wondering if you could update with foreground services and bringing in more clean architecture like less knowledge in the activity about the service, etc. Thanks!
@maysal-reem64574 жыл бұрын
Great video! And could you please make some videos about the whole services thing because it's confusing
@raveen17424 жыл бұрын
I would love to see a service running in the background .... please make a video on it
@amirhusseinpoudineh77010 ай бұрын
Hi Mitch Please answer this ,i want to make a call waiting app , and i want to post a notification when some one call the phone , I did it using Broad Cast Receiver but i want to do it when app is completely close . is this video what i need ?
@HydroHeiperGen5 жыл бұрын
@CodingWithMitch Atfrist, thank you for offering so much of your time to help noobs like me. Your Video is pretty good, but as a experienced Beginner, there are some questions left open. @25.40 As I understood the point of MVVM is to encapsulate the way of getting Data and the displaying of Data, to create a better structured code. So why do we bind the Service to the Activity and pass the ViewModel class instead of starting the Service in the Activity, but bind the service directly to the VM.class? As I understand, in your video, we create a bridge from Service to Activity, which continuous to the VM and the data later on will be send from the VM to the Activity. Can you tell me where I went wrong?
@codingwithmitch5 жыл бұрын
This is actually an anti-pattern btw. You shouldn't bind services like this. Check out this article medium.com/androiddevelopers/viewmodels-and-livedata-patterns-antipatterns-21efaef74a54
@timbraasch15144 жыл бұрын
the MVVM pattern sure is a good pattern, but i wouldnt recommend using it in a guide video since it can confuse newer programmers.
@shyam89996 жыл бұрын
Nice work and please create a video for android oreo background services and background location
@abdulwahid_mohammed6 жыл бұрын
That's so fantastic and useful.
@codingwithmitch6 жыл бұрын
I appreciate the love brother :D
@aminamer52835 жыл бұрын
thank you Mitch... another great video! made ma day ?
@wawa33 жыл бұрын
Wouldn't new handler and runnable be created every time the progressUpdating get onChanged this way?
@IxIAlanIxI5 жыл бұрын
This was the best tutorial I found on the internet about Bound Services, but the fact that it uses MVVM is driving me crazy, because I can not rewrite my whole project to implement MVVM. Does anyone have a version of this code that does not use MVVM? I watched the video about MVVM to try to "remove" it from the code, but unfortunately I could only get my code to stop working.
@rizwansayyed78935 жыл бұрын
No problem just write service binder instance or create service connection in directly activity meaning remove viewmodel and write service code in mai activity which is in viewmodel
@aleksamatic95585 жыл бұрын
what is your favorite architectural design pattern xD?
@carlosalvarez25064 жыл бұрын
Thanks for the video, it was really helpfull
@luvsinha12233 жыл бұрын
awesome video. learned a lot .
@nishantkumar-fl3cy4 жыл бұрын
Please make a video on what can we do on background service thread.
@jacekgawel4 жыл бұрын
Awesome tutorials.. but It is only for simple Services. What when I have a location service which returns ? I can do all that stuff like "calculate distance" "find speed" "change to LatLng" in service and do some getters methods but I thing it isn't right according to mvvm pattern. So I need to observe data in Repository somehow? There is a simple solution for this? Obviously I can get location from bounded service to activity, like you did, then viewmodel.setvalue(location). From viewmodel send to Repository, do the staff, and observe it, but it isn't right, isn't it?
@davidfa74305 жыл бұрын
Thank you for your great video. I have a question that is it possible to given a service bound by multi-activities? so that no matter which activity is running, the service will keep running without re-create?
@nktkumar823 жыл бұрын
This is awesome.Just had one doubt. Is it not wrong to implement the "Service Connection" inside ViewModel as it is against the concept of MVVM as ViewModel should not contain anything related to Android Framework or android framework apis.
@devanshu_on_youtube2 жыл бұрын
That is the ideal case, but I think it's more of a KMM perspective, i.e. if you're targeting multiple platforms like iOS and Android using KMM, it makes sense to encapsulate all business logic in the view-model minus the Android Framework-specific stuff.
@figoaranta35053 жыл бұрын
Hi Mitch, I am new in android development, where do you think is better to access a service, from view or ViewModel? Thanks
@sukhwantsingh5014 жыл бұрын
Great sir.. please share on intent service
@shubamvirdi29074 жыл бұрын
Sir please make a video of integrating exoplayer using services and getting realtime feed from the service of running music.
@moammarqaddafi4858 Жыл бұрын
did you make a video to run service on bg thread?
@aliakkawi47596 жыл бұрын
Thanks a lot. What is the difference between Services and Android Job Scheduler? and when to use each? In one of my projects I used Android Job Scheduler to Schedule Push notifications twice a day. Thanks
@codingwithmitch6 жыл бұрын
Too much to say about that. You should just read internet articles. I don't have a post on the differences.
@ravikumarmohan14154 жыл бұрын
Please make a tutorial of forgroundService for android O and also on WorkManager and AlaramManager with broadcast
@Androidmeda5 жыл бұрын
Really thanks for this lecture, sir. could I ask you, when to use Service, when to use IntentService, when to use JobIntentService?
@ant41975 жыл бұрын
what was the real use case of services like that? in your experience. looks quite difficult to understand if learning it on your own...
@TropicalCoder4 жыл бұрын
I would like to have seen the service callback with progress reports rather than MainActivity polling for progress.
@pawankhandalnasirda Жыл бұрын
hey i am intested in the to run the service on background thread.
@medicalpump92755 жыл бұрын
Dude you are awesome...
@prafulnayak14 жыл бұрын
It is a great tutorial. Can you please make a tutorial for Services for Android O or higher
@mimrankhan99746 жыл бұрын
please make a video on threads with practical example not just print log messages
@banzeirao4 жыл бұрын
sending message to a Handler on a dead thread java.lang.IllegalStateException: Handler (android.os.Handler) {2f8aa543} sending message to a Handler on a dead thread not work
@ILikeItPicasso2 жыл бұрын
If you could have just explained in a simple video, what bound service is and how to implemented it that would have been much nice, using a simple example this video could have been much better and also lesser in time and code. Just like coding in flow. But still thanks :)
@deeprajpandey76125 жыл бұрын
please make a video on background thread
@olegalekos21815 жыл бұрын
I have a guestion.. Let say i want my app to run a service that uses Sensor and calculates Steps and than return each step to Activity. A. Should it be On another Thread so it wont freeze main thread? B. Should it be Bound ?
@021ritvik4 жыл бұрын
Best tutorial ever!
@sourovkarmakar32374 жыл бұрын
can you please make a video on media code API of android
@mohamadnabikazemi67374 жыл бұрын
perfect , thank you
@shoaibmalik9934 Жыл бұрын
How does the whatsapp show there call ui when someone calls
@ofir-bar-softr5 жыл бұрын
Please make a background thread video :)
@chiragprajapati39896 жыл бұрын
nice please make more video on service
@pembatamang82336 жыл бұрын
I put a log under aBoolean in the MainActivity and after the work is over, the aBoolean keeps changing. Why is it happening??
@codingwithmitch6 жыл бұрын
It's supposed to. That means the work is done
@pembatamang82336 жыл бұрын
@@codingwithmitch I don't understand.... the river of true false true false kept going on in my log...is that how it works?? isn't it bad for performance.?? please explain a bit more
@codingwithmitch6 жыл бұрын
@@pembatamang8233 It's the runnable. It's constantly asking the service for updates. Every 100 ms. So if you put a log there, you'll see it run constantly.
@pembatamang82336 жыл бұрын
@@codingwithmitchok... how do i stop it when the work is done??
@codingwithmitch6 жыл бұрын
@@pembatamang8233 Whoops. There was a bug. Good find. Inside the "run" method you can't use "aBoolean" because then it's final. Which defeats the purpose because it will never change. Use "mViewModel.getIsProgressUpdating().getValue()" instead of "aBoolean" inside the run method. gist.github.com/mitchtabian/0621da267a677cabcd1f270e3c6513fa
@ayeshazakria22154 жыл бұрын
pls use microphones for clear voice. thanks
@thesalehmahmood6 жыл бұрын
Haven't watched it yet but Is this video part of that Spotify alike app?
@codingwithmitch6 жыл бұрын
Nope just bound services
@juanpusongjr.31025 жыл бұрын
awesome tutorial.. can you please give a clue how to integrate this on playing an audio.. thanks
how to run activity in the background in the android
@arhamcodes6 жыл бұрын
Please do a video on background thread.
@samuelorji83966 жыл бұрын
checkout his course on Threads, It's on his website and on pluralsight also... It's pretty cool
@codingwithmitch6 жыл бұрын
thanks I noted your response
@giannisfragoulis30944 жыл бұрын
Make a video for infinite running servicee PLEASE
@smit97795 жыл бұрын
Great tutor
@mikys11285 ай бұрын
thx 👍👍🙂
@notsure15166 жыл бұрын
big Mitch
@talatkuyuk65563 жыл бұрын
Very nice tutorial. But as far as I understand, two separate runnable run at the same time in the activity and in the service to show the progress. It could be better, one runnable runs at the service and inform the progress to the activity via broadcast-broastreceiver or LiveData implementation in connection with viewmodel.
@ishankhandelwal7413 жыл бұрын
Awesome
@VonUndZuCaesar4 жыл бұрын
Better: Use AndroidX WorkManager from the new Android Jetpack Library
@vennamprasad Жыл бұрын
please do video
@amirs64724 жыл бұрын
Please make a video on what can we do on background service thread.