我在Android中获得了一项服务,但IntentService
无法知道何时被杀 - 我知道这不是正确使用IntentService(你不应该这样做)调用stopSelf())。
public class VideoService extends IntentService {
@Override
public void onCreate() {
super.onCreate();
mCamera2Video = new Camera2Video();
mCamera2Video.start()
}
@Override
public void onDestroy() {
//My service doesn't know when to be destroyed though!
mCamera2Video.closeCamera();
mCamera2Video.stopBackgroundThread();
}
我需要能够在stopSelf()
实例完成后从mCamera2Video
实例内的某处调用mCamera2Video
。在这种情况下,Service
启动并完成视频录制会话,10秒后自动停止。然后public class Camera2Video
implements MediaRecorder.OnInfoListener {
private void stopRecordingVideo() {
//Notify VideoService that I am complete!!
}
}
需要知道如何关闭。
mCamera2
我该怎么做?我并不熟悉Java,但我想的是:
VideoService
<!DOCTYPE html>
<html>
<head>
...
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script>
$(function(){
$("#header").load("../header/index.html");
$("#footer").load("../footer/index.html");
});
</script>
<link rel="stylesheet" href="../header/style.css">
<link rel="stylesheet" href="../footer/style.css">
</head>
<body>
<div id="header"></div>
<section>
<div>
<input type="image" src="search.png" id="submitKeywordButton" onclick="submitKeyword();" />
<div style="overflow: hidden;">
<input type="text" name="subscribe" placeholder="keyword" id="keyword"/>
</div>
</div>
</section>
<div id="footer"></div>
<script src="./main.js"></script>
</body>
</html>
实例
谢谢!