title: Flashlight for Android on Kotlin
body: <p>You need to turn on the LED on your phone. I wrote a simple application. The LED should turn on when the app starts. The code matches the solutions on Stackoverflow
  Application code:</p>
  <pre><code>package com.example.flash
  
  import android.hardware.Camera
  import androidx.appcompat.app.AppCompatActivity
  import android.os.Bundle
  
  class MainActivity : AppCompatActivity() {
  
   override fun onCreate(savedInstanceState: Bundle?) {
       super.onCreate(savedInstanceState)
       setContentView(R.layout.activity_main)
       var cam = Camera.open()
       var p = cam.parameters
       p.flashMode = Camera.Parameters.FLASH_MODE_TORCH
       cam.parameters = p
       cam.startPreview()
   }
  } 
  </code></pre>
  <p>AndroidManifest.xml:</p>
  <pre><code>    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
      &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.example.kgskassa&quot;&gt;
         &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
         &lt;uses-permission android:name=&quot;android.permission.CAMERA&quot; /&gt;
         &lt;uses-permission android:name=&quot;android.permission.FLASHLIGHT&quot;/&gt;
         &lt;uses-feature android:name=&quot;android.hardware.camera&quot; /&gt;
         &lt;uses-feature android:name=&quot;android.hardware.camera.autofocus&quot;/&gt;
  </code></pre>
  <p>Access to the camera on the phone is allowed.
  Does not work. Ideas?</p>