Skip to content

Commit 333727c

Browse files
committed
fix stroboscope on some devices, by sarevd
1 parent 90f1e30 commit 333727c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/src/main/java/com/simplemobiletools/flashlight/MyCameraImpl.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.simplemobiletools.flashlight;
22

33
import android.content.Context;
4+
import android.graphics.SurfaceTexture;
45
import android.hardware.Camera;
56
import android.os.Handler;
67
import android.util.Log;
78

89
import com.squareup.otto.Bus;
910

11+
import java.io.IOException;
12+
1013
public class MyCameraImpl {
1114
private static final String TAG = MyCameraImpl.class.getSimpleName();
1215

@@ -223,6 +226,15 @@ public void run() {
223226
torchOn.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
224227
torchOff.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
225228

229+
SurfaceTexture dummy = new SurfaceTexture(1);
230+
try {
231+
mCamera.setPreviewTexture(dummy);
232+
} catch (IOException e) {
233+
Log.e(TAG, "setup stroboscope1 " + e.getMessage());
234+
}
235+
236+
mCamera.startPreview();
237+
226238
while (!mShouldStroboscopeStop) {
227239
try {
228240
mCamera.setParameters(torchOn);
@@ -244,8 +256,8 @@ public void run() {
244256
mCamera = null;
245257
}
246258
}
247-
} catch (RuntimeException ignored) {
248-
259+
} catch (RuntimeException e) {
260+
Log.e(TAG, "setup stroboscope2 " + e.getMessage());
249261
}
250262
}
251263

0 commit comments

Comments
 (0)