if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
startService(new Intent(this, Smart113MainService.class));
}
else {
startForegroundService(new Intent(this, Smart113MainService.class));
}
移动
startForeground
编码到
onCreate()
@Override
public void onCreate() {
...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForeground(NOTIFICATION_ID, notification);
}
...
}
删除通知
onDestroy()
@Override
public void onDestroy() {
...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
stopForeground(true); //true will remove notification
}
...
}
您没有在不同的进程中获得调试点,因为您正在从附加调试器中选择主进程。选择要调试的正确进程。