English 中文(简体)
无法在银河 Nexus 中使用手电筒
原标题:Unable to use the flashlight in Galaxy Nexus

我必须遵循代码,我只是想打开我的银河Nexus(4.02)的手电筒,但是它没有这样做。

public class welcome extends Activity {

//MediaPlayer player;
/** Called when the activity is first created. */
@Override

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.welcome);

    Camera cam = Camera.open();     
    Parameters p = cam.getParameters();
    p.setFlashMode(Parameters.FLASH_MODE_TORCH);
    cam.setParameters(p);
    cam.startPreview();



}
}

我的表单文件 :

<uses-sdk android:minSdkVersion="12" />
       <uses-permission android:name="android.permission.CAMERA" />
 <uses-feature android:name="android.hardware.camera" />

I would like to ask if it is my coding error or android version problem? Thanks

问题回答

银河系连结无法使用闪光, 除非有附着的表面视图和表面控件。 我有自己的 Nexus, 并在附加预览视图后有效 。 既然您不想看到相机在手电筒应用程序中看到什么, 只需把它做成 1x1 像素 。

资料来源:没有作用。

Have you tried the code here: http://android-er.blogspot.co.uk/2011/02/control-flash-light-function-as-torch.html

它绝对是用一个扎根的欲望运行着7型氰化物,用ICS rom(4.4.3)对我起作用。也许尝试运行它,看看它是否有效,然后从那里开始?

它还包括检查以查看它能否找到相机,然后打开相机。 似乎没有必要进行 StartPreview () 。

事件顺序似乎不同:

1: If camera is present, open camera 2: Set parameters 3: parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
4: camera.setParameters(parameters);

Use surface view to attach camera as some of the devices needs surface view. I am sure this will work a link! for you





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签