我打电话服务从应用程序类,如果我关闭应用程序或从当前正在运行的应用程序中删除,则服务将自动销毁,我没有写任何代码destroy()方法服务将关闭,如果我关闭我的应用程序
来电来访服务代码:
Intent syncIntent = new Intent(this, ScanBLE_Service.class);
this.startService(syncIntent);
这里是服务类的代码
public class ScanBLE_Service extends IntentService {
public ScanBLE_Service() {
super(ScanBLE_Service.class.getName());
// TODO Auto-generated constructor stub
mHandler = new Handler();
}
@Override
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
demo();
}}
private void demo() {
mHandler.removeCallbacksAndMessages(null);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), "Demoooo", Toast.LENGTH_SHORT).show();
demo();
}
}, 5000
);
}
这是出乎意料的,因为? –
这不是预期的行为,你能粘贴你的服务代码吗? –
发布您的服务分类 –