In this Android Service Example we will see a very simple example to understand how to create and implement a service in Android. A service is used for long …

Nguồn:https://u-os.org/

Xem Thêm Bài Viết Khác:https://u-os.org/cong-nghe

Author

43 Comments

  1. Danish Ali Reply

    i did the same but when i destroy the app music closed?
    can u explain

  2. Oh my god! Man, you saved my life!!! It's working perfectly, I've tested it out on my phone! Thank you so much

  3. Will you please make a video on how to use seekbar with in the service

  4. Shahriyar Guliyev Reply

    Thanks a bunch to teach this simple example which is what I need to know about introduction to Android services 👐

  5. Deepak shah Reply

    I have done all code same as yours.

    Only one issue 👇
    But after clearing recent apps sound is not playing.

  6. could you not have the beep so loud hahaha, thanks anyway

  7. Thuy Ha Van Reply

    You play music on Main thread (This is not good solution)

  8. martin white Reply

    thanks the video is great
    but my question is that i want the music to play even when the screen is off
    how do i do it???

  9. This background service is destroy itself when user send app to bakcground.

  10. Raggy Rags Reply

    bro how to add a mp3 file instead of a default ringtone?

  11. Mostafa Gad Reply

    Good , can u explain how to pause and communicate media player from background service with seek bar in activity ??

  12. U U UjjwalSquare Reply

    Sir I don't know why in my nougat mobile song is stop as I remove app from recent menu

  13. Abdel Ibrahim Reply

    great tutorial .You can override methods by only hitting ctrl+O

  14. Michael Burrows Reply

    Thanks for the effort but you need to speak up or turn up the volume

  15. Mostafa Gad Reply

    How can update seekbar in activity with media player running in service ??

  16. Vishnu Prasanth Reply

    The dislikes are probably because of your ringtone xD

  17. Ioan Oltean Reply

    My app keeps crashing when i try to start/stop
    copyed it tho

  18. Aliton Oliveira Reply

    Good tutorial! How to start an activity simultaneously with the service and pass data info (like Author, year and song's name) to the simultaneous activity?

  19. Nathanael Newton Reply

    I followed these instructions but when i press the start/stop service buttons nothing happens D:

  20. Gürkan Luş Reply

    I want the music to continue even ı kill the app? ı do notifications but dont work as which ı want

  21. Akansha Kaushik Reply

    thanks for the video..finally a simple understandable video ..great work..keep sharing

  22. aditya abhiram Reply

    The code is not working .
    It doesn't solve the main need of service. It does't run in background after removing app from ram. We even copy pasted the code an it doesn't work.

  23. Muhamad Eawedat Reply

    Since Oreo, this code will not work, please refer to: https://developer.android.com/about/versions/oreo/background

  24. Alina Zachia Reply

    STOP SERVICE BUTTON DOES NOT WORK I JUST PLAY SERVICE AND IT IS NOT STOPPING THE STOP BUTTON DOES NOT WORK – HELP !!!!

  25. Karan Bagal Reply

    PostResponseAsyncTask task = new PostResponseAsyncTask(SampleService.this, data, (AsyncResponse) this);

    task.execute(path+"emp_latlong.php");

    How to use this method in services

  26. Tahir Khan Reply

    well explanation ,
    but what the hell is this background music.

  27. well fck you with your loop, you intentionally let that wtf

  28. It works fine, but after sometimes it stops working ?
    Any help please ,

  29. Talha Shahab Reply

    Bro when i call the service from java file like this (new Intent(this,Myservice.class));then it gave me error what is solution

  30. Nguyen Thanh Hieu Reply

    Hi, I have just studied android, I used this service to play background music from Activity A –> Activity B and music will stop when jump to Activity C. But when I back to Activity B or A, music also stop. How I can do when back to Activity B or A, music will restart?

Write A Comment