Cho mình hỏi:
Theo docs của android thì
A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity. Another component, such as an activity, can start the service and let it run or bind to it in order to interact with it. A service is implemented as a subclass of Service and you can learn more about it in the Services developer guide.
So, as long as you create a service, and the user exits your app it will still run. Just like the example above.
Theo nó nói thì service chạy độc lập với activity khi tắt app nó vẫn chạy, nhưng sao mình thử cho phát nhạc bằng MediaPlayer trong Service thì tắt app nó tắt nhạc theo luôn.
Đã thử dùng startForeGround() với Notification, nhưng mới dùng lần đầu nên nó ko work.
Đây là hàm onStartCommand() trong MyService.java của mình
Giờ làm sao để nó hoạt động nhỉ? Cảm ơn mọi người!
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?