0
我試圖捕捉到通過攝像機圖像中後臺服務調用相機類多次,但在這樣做我的應用程序越來越吊死,有的時候它給了我失敗的「錯誤連接到相機服務「雖然我的應用程序用戶界面每20秒鐘都會收到我的圖片,但要麼被吊死,要麼崩潰。應用越來越被絞死時,試圖通過服務
請對我的服務類一看: -
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
captureImage();
}
private void captureImage() {
int count = 0;
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (IS_ACTIVITY_FINISHED) {
count++;
if (count == 20) {
// Start Activity here
Intent translucent = new Intent(getApplicationContext(),
HiddenCamera.class);
translucent.putExtra("FLASH", "off");
translucent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(translucent);
IS_ACTIVITY_FINISHED = false;
break;
}
}
}
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
這裏是我的HiddenCamera類: -
http://piratepad.net/ep/pad/view/ro.LgLDgdzewfJ/latest
我的清單文件: -
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<service android:name="com.example.services.CameraService" >
</service>
請向我提供有關此過程的任何有用信息。
感謝