如此多的LED手电筒API问题适用于Android.我不敢问另一个,但是这里......
使用经过验证的真实FLASH_MODE_TORCH,我可以满足我的三星Galaxy SII并启用LED闪光灯.在我朋友的Galaxy Nexus上,没有这样的运气.也不是我的另一个朋友的Droid X.
我注意到似乎需要特定的本机IOCTL调用的设备数量不是很少.这是Galaxy Nexus的情况吗?我如何找到编程参考?
我正在做标准的FLASH_MODE_TORCH /"flash-mode"="torch",startPreview()链.
令人失望的是,这个看似标准的API似乎并不是那么普遍.
我正在编写一个Android相机应用程序,并试图实现Flash功能,我正在使用SurfaceView,每当我点击闪光按钮切换工作但闪光灯不会来...看到我以下的代码,我已经习惯打开/关闭手电筒.
完整代码: -
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera);
preview=(SurfaceView)findViewById(R.id.surface);
previewHolder=preview.getHolder();
previewHolder.addCallback(surfaceCallback);
previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
previewHolder.setFixedSize(getWindow().getWindowManager()
.getDefaultDisplay().getWidth(), getWindow().getWindowManager()
.getDefaultDisplay().getHeight());
btnFlash = (ImageButton) findViewById(R.id.btnFlash);
/*
* First check if device is supporting flashlight or not
*/
hasFlash = getApplicationContext().getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
if (!hasFlash) {
// device doesn't support flash
// Show alert message and close the application
AlertDialog alert = new AlertDialog.Builder(CameraLauncherActivity.this)
.create();
alert.setTitle("Error");
alert.setMessage("Sorry, your device doesn't support flash light!");
alert.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { …Run Code Online (Sandbox Code Playgroud)