简体   繁体   English

在Nexus S和Galaxy SII中从小部件打开相机

[英]Turn on Camera from widget in Nexus S and Galaxy SII

Problem Description 问题描述

I am writing a simple Widget for Android Devices. 我正在为Android设备编写一个简单的小部件。 When user press on the widget a Camera Flashlight must turn Off and On. 当用户按下小部件时,相机手电筒必须关闭和打开。 My Widget works fine when I launch it on Sony Ericsson Arc, but when I try to launch Widget on Samsung NexusS or Samsung Galaxy SII it do nothing (doesn't work) . 当我在索尼爱立信Arc上启动Widget时,我的Widget正常运行,但是当我尝试在Samsung NexusSSamsung Galaxy SII上启动Widget时,它什么也不做(不起作用)


Researches 研究成果

I google this issue and find some answers for it. 我用Google搜索这个问题,并找到了一些答案。 Most of users suggest to use SurfaceView and really surface view with size 1 pixel really work if it is placed on activity, but it doesn't work in my case (Widget doesn't support SurfaceViw) . 大多数用户建议使用SurfaceView,如果将其放置在活动上,则实际上可以使用尺寸为1像素的表面视图,但是在我的情况下它不起作用(窗口小部件不支持SurfaceViw)

LED flashlight on Galaxy Nexus controllable by what API? Galaxy Nexus上的LED手电可由什么API控制?

I found this article and it was very useful, but how can I use it in my case, in the case if I want turn on light from widget ? 我找到了这篇文章,它非常有用,但是如果我想打开小部件的灯,该如何使用呢? I know that I can't use Surface view in Widget View as it is not supported yet, any Ideas ? 我知道我无法在Widget视图中使用Surface视图,因为尚不支持它,是不是有任何想法?


Question

Please provide me some links, open source projects or articles or something that can be helpful on how I can turn light on/off from the widget on Nexus S One and Galaxy S II. 请提供一些链接,开源项目或文章,或者对我如何从Nexus S One和Galaxy S II上的小部件打开/关闭照明有帮助的内容。

Is there any universal code for working with camera on different phones ? 是否有用于在不同手机上使用相机的通用代码? Any information will be helpful. 任何信息都会有所帮助。

Maybe I need to use native library ? 也许我需要使用本机库?

Thanks. 谢谢。

There is no official android API allowing you to manipulate camera flash alone. 没有官方的android API,不允许您单独操作相机闪光灯。 You have to go via official camera API - and it does not formally define how to manipulate flash LED. 您必须通过官方的相机API-它没有正式定义如何操作闪光灯LED。 YOu can set different modes, but camera software can ignore it at will. 您可以设置不同的模式,但是相机软件可以随意忽略它。

So, if this works on sony it does not have to vork for other hardware. 因此,如果这在Sony上可行,则不必为其他硬件而烦恼。 There could be (and most probably there are) some vendor specific undocumented APIs though. 但是可能有(并且很可能有)一些供应商特定的未记录API。

A bit late in response,however, the camera has to pass a surface on some devices in order to turn flash on. 但是,响应晚了一点,但是相机必须通过某些设备的表面才能开启闪光灯。 Given that surface view is not applicable, you need to implement a surface texture instead, available as of api 11 鉴于表面视图不适用,您需要改为实现表面纹理,此纹理自api 11起可用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM