活动停止时不要停止服务

时间:2013-06-11 20:13:52

标签: android android-service

我想知道如何启动即使在业务关闭时仍继续运行的Android服务。

我使用此代码:

Intent intent = new Intent(this, MyTestService.class);          
bindService(intent,connection, Context.BIND_AUTO_CREATE);

谢谢。

2 个答案:

答案 0 :(得分:2)

 Intent intent = new Intent(this, MyTestService.class);   
 startService(intent);

答案 1 :(得分:1)

你可以尝试

startService(new Intent(this, MyTestService.class));

之前

Intent intent = new Intent(this, MyTestService.class);  
相关问题