Making a simple strobe light out of my camera's flash feature.
I can't figure out why I'm getting an error on lines 31 and 32 for the
Here's my activity;cam.stopPreview(); cam.release();
Here's my layout.xml file;package com.Strobe; import android.app.Activity; import android.content.pm.PackageManager; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.os.Bundle; public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); for (int i=1;i<1000;i++) { for (int j=1;j<2;j++) { Camera cam = Camera.open(); Parameters p = cam.getParameters(); p.setFlashMode(Parameters.FLASH_MODE_TORCH); cam.setParameters(p); cam.startPreview(); } cam.stopPreview(); cam.release(); } } }
Thanks in advance!<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:screenOrientation="portrait" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Hello World, MainActivity" /> </LinearLayout> <permission android:name="android.permission.FLASHLIGHT" android:permissionGroup="android.permission-group.HARDWARE_CONTROLS" android:protectionLevel="normal" android:label="@string/permlab_flashlight" android:description="@string/permdesc_flashlight" />