Note that there are some explanatory texts on larger screens.

plurals
  1. POFlashlight (LED BACK) on/off, camera null HTC
    primarykey
    data
    text
    <p>I'm practicing and trying to change the flashlight (torch) on the back of my HTC. But I get no camera access, I put in the manifest the following:</p> <blockquote> <pre><code>&lt;uses-permission android:name="android.permission.FLASHLIGHT" android:permissionGroup="android.permission-group.HARDWARE_CONTROLS" android:protectionLevel="normal"/&gt; &lt;uses-permission android:name="android.permission.CAMERA"/&gt; &lt;uses-feature android:name="android.hardware.camera.flash" /&gt; </code></pre> </blockquote> <p>It can be very simple and stupid, but google and StackOverflow didn't gave me a solution, so can anybody tell me what I'm doing wrong? This is my activity file:</p> <pre><code>import android.app.Activity; import android.content.Intent; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.os.Bundle; import android.widget.*; import android.view.View; import android.util.Log; import java.util.List; public class FlashlightActivity extends Activity { private Camera mCamera; /** Called when the activity is first created, just a titlescreen. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageButton titlescreen = (ImageButton)findViewById(R.id.titlescreen); titlescreen.setOnClickListener(new View.OnClickListener() { public void onClick(View v){ TurnFlashOff(); if (mCamera==null){ finish();} else { Intent go = new Intent(TurnMeOnFlashlightActivity.this,TMO_App.class); startActivity(go); } } }); Log.d("TurnMeOn", "startpage"); } private void TurnFlashOff(){ if(mCamera != null){ mCamera = Camera.open(); Parameters params = mCamera.getParameters(); List&lt;String&gt; flashModes = params.getSupportedFlashModes(); if (flashModes.contains(Parameters.FLASH_MODE_TORCH)) { params.setFlashMode(Parameters.FLASH_MODE_OFF); mCamera.setParameters(params); mCamera.release(); mCamera = null; } else { Toast.makeText(TurnMeOnFlashlightActivity.this, R.string.FlashNoSupport, Toast.LENGTH_LONG).show(); mCamera.release(); mCamera = null; } } else { Toast.makeText(TurnMeOnFlashlightActivity.this, R.string.FlashNoSupport, Toast.LENGTH_LONG).show(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload