清理数据时停止服务 [英] Service stops when clearing data

查看:87
本文介绍了清理数据时停止服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了与本地数据库进行通信通知服务

I created a notification service which communicate with the local database

在我的应用程序运行时preSS设置清除数据按钮,
该服务也将停止。但我需要保持业务正常运行,同时清洗
数据库(用于测试)。做到这一点通常发生。

When i press Settings Clear Data button while the application is running, the service also stops. but i need to keep the service running while cleaning the database (for testing). does this normally happens.

在此先感谢

更新

我使用IntentService创建后台服务。我试图重新启动服务时
发生这种情况。我发现从onStartCommand返回START_STICKY服务可以重新启动。但在IntentService,它说不要覆盖此方法的方法。有没有办法做到这一点
再次感谢

I'm using IntentService to create the background service. I'm trying to restart service when this happens. I found out that returning START_STICKY from onStartCommand the service can be restarted. but in IntentService , it says not to overide this method. is there any way to do this thanks again

推荐答案

在回答::

我使用IntentService创建后台服务。我想遇到这种情况时重新启动服务。我发现从onStartCommand返回START_STICKY服务可以重新启动。但在IntentService,它说不要覆盖此方法的方法。

I'm using IntentService to create the background service. I'm trying to restart service when this happens. I found out that returning START_STICKY from onStartCommand the service can be restarted. but in IntentService , it says not to overide this method.

他们重写该方法<一href=\"http://developer.android.com/reference/android/app/Service.html#onStartCommand%28android.content.Intent,%20int,%20int%29\"相对=nofollow>这里 -

They have overridden that method here-

这篇关于清理数据时停止服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆