【发布时间】:2019-03-30 17:46:23
【问题描述】:
我有我的应用程序运行抖动检测服务,但是在我的 MainActivity 中,我有注销用户的按钮,我必须在其中注销并终止检测到抖动事件的服务。
我在 MainActivity 中注销的方法是:
public void signOutAndFinish(){
//Stop Shakeservice
Intent intent = new Intent(this, ShakeService.class);
stopService(intent);
//Go to login activity
Intent iLoginView = new Intent(this, LoginActivity.class);
startActivity(iLoginView);
}
但是,如果我在退出后摇晃我的设备,服务会识别摇晃,就好像它不会立即杀死它:
Intent intent = new Intent(this, ShakeService.class);
stopService(intent);
onDestroy方法中的代码是:
@Override
public void onDestroy() {
super.onDestroy();
}
我怎样才能终止服务,以便在我注销时服务死掉?
感谢您的帮助!
【问题讨论】:
标签: java android android-service