Bound Services on Android

Поділитися
Вставка
  • Опубліковано 10 гру 2024

КОМЕНТАРІ • 120

  • @cnsnmms3708
    @cnsnmms3708 4 роки тому +5

    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

  • @trollrar
    @trollrar 5 років тому +38

    Background thread service tutorial please :)

  • @TechMalaya
    @TechMalaya 5 років тому

    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.

  • @atifmbhutta
    @atifmbhutta 4 роки тому

    Damnn Mitch you are the best. Precise and to the point. Very well explained videos always.

  • @АлексейРодионов-ы8о

    The best tutorial on services I ever seen

  • @muneerhasan
    @muneerhasan 4 роки тому

    This video about service is best video on services.
    This video cleared my all doubt 💯💯.
    Thanks a lot Mitch

  • @kunalsahu4
    @kunalsahu4 3 роки тому

    Thank you so much Mitch, that very cool explanation. I request you to please create more content on Services and running task in BG

  • @satyamsharma8240
    @satyamsharma8240 3 роки тому

    Love the way you made everything so simple

  • @Since1059
    @Since1059 4 роки тому

    Really Really Really so nice and clean directions about bind services
    😘😘😘😘

  • @Priyanshu-nq8rm
    @Priyanshu-nq8rm Рік тому

    Thanks Mitch for an awesome tutorial ☺️

  • @nandandesai6524
    @nandandesai6524 6 років тому +3

    How can you run a service in a background thread? Please please make a video on it. Thanks!

  • @bjugdbjk
    @bjugdbjk 5 років тому +3

    Fabulous explanation, Thank you so much, Appreciate your efforts.

  • @developerkang3717
    @developerkang3717 3 роки тому

    this is exactly What i neeed!! Thank you from South korea

  • @AnkurJagani1000
    @AnkurJagani1000 5 років тому +6

    That will be great if you can make video on startForegroundServices which is must for Android O devices.

  • @amitabhsarkar9571
    @amitabhsarkar9571 5 років тому +6

    Please make a tutorial of forgroundService for android O.

  • @virus2028
    @virus2028 3 роки тому

    Good work, thanx for the lecture man. Helped a lot

  • @maheswaranmohan542
    @maheswaranmohan542 4 роки тому +2

    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....

  • @ankitrajdwivedi996
    @ankitrajdwivedi996 6 років тому +10

    Yes we need video on background thread

  • @alirzayucefaydal591
    @alirzayucefaydal591 6 років тому

    my mind blown :D i believe we need to go deeper and do more exercises with ur help :D

  • @amremam8937
    @amremam8937 4 роки тому +1

    I would be great if you have added an example of aidl in this video

  • @ChrisAthanas
    @ChrisAthanas 4 роки тому

    Some engagement getting you to 100k

  • @mirkaram548
    @mirkaram548 5 років тому

    Make video on Starting service in ANDROID.O and changes in O. Your explanation is amazing with architectural design.

  • @luvsinha1223
    @luvsinha1223 3 роки тому

    awesome video. learned a lot .

  • @TheMikkelet
    @TheMikkelet 3 роки тому

    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

  • @abdulwahid_mohammed
    @abdulwahid_mohammed 6 років тому +1

    That's so fantastic and useful.

  • @moammarqaddafi4858
    @moammarqaddafi4858 Рік тому

    did you make a video to run service on bg thread?

  • @guillermoperez8250
    @guillermoperez8250 4 роки тому

    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();

  • @timbraasch1514
    @timbraasch1514 4 роки тому +2

    the MVVM pattern sure is a good pattern, but i wouldnt recommend using it in a guide video since it can confuse newer programmers.

  • @wawa3
    @wawa3 3 роки тому

    Wouldn't new handler and runnable be created every time the progressUpdating get onChanged this way?

  • @aleksamatic9558
    @aleksamatic9558 4 роки тому +2

    what is your favorite architectural design pattern xD?

  • @aminamer5283
    @aminamer5283 5 років тому

    thank you Mitch... another great video! made ma day ?

  • @Androidmeda
    @Androidmeda 5 років тому +3

    Really thanks for this lecture, sir. could I ask you, when to use Service, when to use IntentService, when to use JobIntentService?

  • @pawankhandalnasirda
    @pawankhandalnasirda Рік тому

    hey i am intested in the to run the service on background thread.

  • @carlosalvarez2506
    @carlosalvarez2506 4 роки тому

    Thanks for the video, it was really helpfull

  • @medicalpump9275
    @medicalpump9275 5 років тому

    Dude you are awesome...

  • @deeprajpandey7612
    @deeprajpandey7612 5 років тому +1

    please make a video on background thread

  • @nishantkumar-fl3cy
    @nishantkumar-fl3cy 4 роки тому

    Please make a video on what can we do on background service thread.

  • @amirhusseinpoudineh770
    @amirhusseinpoudineh770 8 місяців тому

    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 ?

  • @realtimeexperience4470
    @realtimeexperience4470 4 роки тому

    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.

  • @dineshchoudhary8221
    @dineshchoudhary8221 6 років тому +1

    Yes please do a video on running services in a background thread

  • @021ritvik
    @021ritvik 4 роки тому

    Best tutorial ever!

  • @devanshu_on_youtube
    @devanshu_on_youtube Рік тому

    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.

  • @raveen1742
    @raveen1742 4 роки тому

    I would love to see a service running in the background .... please make a video on it

  • @ryszardmachmudow9175
    @ryszardmachmudow9175 2 роки тому

    I read ViewModel should not contain services, because Service has it's own lifecycle. Service field will lead to context leak.

  • @shawngardner261
    @shawngardner261 3 роки тому

    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!

  • @shoaibmalik9934
    @shoaibmalik9934 Рік тому

    How does the whatsapp show there call ui when someone calls

  • @ant4197
    @ant4197 5 років тому

    what was the real use case of services like that? in your experience. looks quite difficult to understand if learning it on your own...

  • @maysal-reem6457
    @maysal-reem6457 4 роки тому

    Great video!
    And could you please make some videos about the whole services thing because it's confusing

  • @capitalcouch5095
    @capitalcouch5095 6 років тому +1

    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 :)

    • @codingwithmitch
      @codingwithmitch  6 років тому +1

      Hey, it's camtasia.

    • @codingwithmitch
      @codingwithmitch  6 років тому

      What kind of videos will you be making? Like what topics?

    • @capitalcouch5095
      @capitalcouch5095 6 років тому

      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?

    • @codingwithmitch
      @codingwithmitch  6 років тому

      @@capitalcouch5095 if you are looking to maximize attention then definitely beginner stuff. The unfortunate thing about that is it gets very boring lol

    • @capitalcouch5095
      @capitalcouch5095 6 років тому

      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?

  • @banzeirao
    @banzeirao 3 роки тому

    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

  • @figoaranta3505
    @figoaranta3505 2 роки тому

    Hi Mitch, I am new in android development, where do you think is better to access a service, from view or ViewModel? Thanks

  • @ravikumarmohan1415
    @ravikumarmohan1415 4 роки тому +1

    Please make a tutorial of forgroundService for android O and also on WorkManager and AlaramManager with broadcast

  • @szymek16s
    @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.

  • @nodajifi
    @nodajifi 4 роки тому

    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?

  • @olegalekos2181
    @olegalekos2181 5 років тому

    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 ?

  • @mohamadnabikazemi6737
    @mohamadnabikazemi6737 4 роки тому

    perfect , thank you

  • @codingwithmitch
    @codingwithmitch  6 років тому

    ******************** 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

  • @davidfa7430
    @davidfa7430 5 років тому

    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?

  • @shubamvirdi2907
    @shubamvirdi2907 4 роки тому

    Sir please make a video of integrating exoplayer using services and getting realtime feed from the service of running music.

  • @ofir-bar-softr
    @ofir-bar-softr 5 років тому +2

    Please make a background thread video :)

  • @TropicalCoder
    @TropicalCoder 4 роки тому

    I would like to have seen the service callback with progress reports rather than MainActivity polling for progress.

  • @ramakrishnap5732
    @ramakrishnap5732 4 роки тому

    how to run activity in the background in the android

  • @HydroHeiperGen
    @HydroHeiperGen 5 років тому

    @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?

    • @codingwithmitch
      @codingwithmitch  5 років тому

      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

  • @shyam8999
    @shyam8999 6 років тому +2

    Nice work and please create a video for android oreo background services and background location

  • @jacekgawel
    @jacekgawel 4 роки тому

    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?

  • @aliakkawi4759
    @aliakkawi4759 6 років тому

    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

    • @codingwithmitch
      @codingwithmitch  6 років тому

      Too much to say about that. You should just read internet articles. I don't have a post on the differences.

  • @nktkumar82
    @nktkumar82 3 роки тому

    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_youtube
      @devanshu_on_youtube Рік тому

      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.

  • @IxIAlanIxI
    @IxIAlanIxI 5 років тому

    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.

    • @rizwansayyed7893
      @rizwansayyed7893 5 років тому

      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

  • @sourovkarmakar3237
    @sourovkarmakar3237 4 роки тому

    can you please make a video on media code API of android

  • @pembatamang8233
    @pembatamang8233 6 років тому

    I put a log under aBoolean in the MainActivity and after the work is over, the aBoolean keeps changing. Why is it happening??

    • @codingwithmitch
      @codingwithmitch  6 років тому

      It's supposed to. That means the work is done

    • @pembatamang8233
      @pembatamang8233 6 років тому

      @@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

    • @codingwithmitch
      @codingwithmitch  6 років тому

      @@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.

    • @pembatamang8233
      @pembatamang8233 6 років тому

      @@codingwithmitchok... how do i stop it when the work is done??

    • @codingwithmitch
      @codingwithmitch  6 років тому

      @@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

  • @sukhwantsingh501
    @sukhwantsingh501 4 роки тому

    Great sir.. please share on intent service

  • @mimrankhan9974
    @mimrankhan9974 5 років тому

    please make a video on threads with practical example not just print log messages

  • @ILikeItPicasso
    @ILikeItPicasso 2 роки тому +1

    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 :)

  • @thesalehmahmood
    @thesalehmahmood 6 років тому

    Haven't watched it yet but Is this video part of that Spotify alike app?

  • @ayeshazakria2215
    @ayeshazakria2215 3 роки тому

    pls use microphones for clear voice.
    thanks

  • @prafulnayak1
    @prafulnayak1 4 роки тому

    It is a great tutorial. Can you please make a tutorial for Services for Android O or higher

  • @chiragprajapati3989
    @chiragprajapati3989 6 років тому

    nice please make more video on service

  • @ishankhandelwal741
    @ishankhandelwal741 2 роки тому

    Awesome

  • @smit9779
    @smit9779 5 років тому

    Great tutor

  • @arhamcodes
    @arhamcodes 6 років тому

    Please do a video on background thread.

    • @samuelorji8396
      @samuelorji8396 6 років тому +2

      checkout his course on Threads, It's on his website and on pluralsight also... It's pretty cool

    • @codingwithmitch
      @codingwithmitch  6 років тому +1

      thanks I noted your response

  • @mikys1128
    @mikys1128 3 місяці тому

    thx 👍👍🙂

  • @giannisfragoulis3094
    @giannisfragoulis3094 3 роки тому

    Make a video for infinite running servicee PLEASE

  • @juanpusongjr.3102
    @juanpusongjr.3102 5 років тому

    awesome tutorial.. can you please give a clue how to integrate this on playing an audio.. thanks

    • @codingwithmitch
      @codingwithmitch  5 років тому +2

      Boom codingwithmitch.com/courses/android-audio-streaming/

  • @notsure1516
    @notsure1516 6 років тому +1

    big Mitch

  • @talatkuyuk6556
    @talatkuyuk6556 3 роки тому

    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.

  • @vennamprasad
    @vennamprasad Рік тому

    please do video

  • @VonUndZuCaesar
    @VonUndZuCaesar 4 роки тому

    Better: Use AndroidX WorkManager from the new Android Jetpack Library

  • @amirs6472
    @amirs6472 4 роки тому

    Please make a video on what can we do on background service thread.

  • @sorousheskandary-l7q
    @sorousheskandary-l7q Місяць тому

    Background thread service tutorial please :)