Why doesn't my Service work in Android? (I just want to log something ever 5 seconds)

后端 未结 5 783
攒了一身酷
攒了一身酷 2020-12-14 18:44

I created a new class called HelloService. I added this to the Android manifest.xml.

public class HelloService extends Service {
    private Timer timer = ne         


        
5条回答
  •  离开以前
    2020-12-14 19:07

    A service has a life cycle as any other android application. For this reason it can occur that your service gets killed by the system (see Service documentation). The right way to implement this is using Alarm Manager as discussed in Android service stops.

提交回复
热议问题