IntentService即使应用程序被杀,我也想继续在后台运行.并且被"杀死"我的意思是按住主页按钮很长时间 - > 查看所有正在运行的应用程序 - >将我的应用程序放在一边 - > 应用程序被杀或按下后退按钮很长时间 - > 应用程序被杀
我的代码如下.在我的MainActivity中:
Intent intent = new Intent(this, MyService.class);
this.startService(intent);
Run Code Online (Sandbox Code Playgroud)
在我的MyService中:
public class MyService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
System.out.println("MyService started");
run();
}
private void run() {
while (true){
System.out.println("MyService still running");
doSomething();
waitSomeTime();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我看到应用程序打开时服务正在运行.当我通过主页按钮最小化应用程序时,它仍在运行.当我通过后退按钮关闭应用程序时,它仍在运行.但如果我如上所述杀死它,它就会停止.我该如何解决这个问题?
我想通过Javascript创建一个DIV元素,但它应该有onMouseOver效果.
所以我知道HTML中的标签是什么样的:
<div onMouseOver="doSth()" onMouseOut="doSthElse()"> </div>
Run Code Online (Sandbox Code Playgroud)
而且我知道如何创建我的DIV:
var myDiv= document.createElement("div");
//style settings
document.body.appendChild(myDiv);
Run Code Online (Sandbox Code Playgroud)
但是如何在Javascript代码中创建效果?