La versión apk de la linterna es diferente?

Tengo una linterna apk con dos problemas. Si uso camera, camera.parameters. Mi apk trabajando con versiones inferiores de Android 5. THen si uso camera2 y camera.manager, Mi aplicación funciona con Android 5 y versiones más altas.

Quiero trabajar con la versión 4 de Android y más, trabajar con todas las versiones. ¿Cómo puedo hacer esto?

Pls me ayuda para esto, gracias.

package com.hallac.erdogan.spechflash; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.hardware.Camera; import android.hardware.camera2.CameraAccessException; import android.hardware.camera2.CameraManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.ImageButton; public class MainActivity extends AppCompatActivity { ImageButton btnSwitch; ImageButton flashlight; private Camera camera; private boolean isFlashOn; private boolean hasFlash; Camera.Parameters params; private CameraManager mCameraManager; private String mCameraId; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE);//full keran ile ilgili ayarlar getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,//full keran ile ilgili ayarlar WindowManager.LayoutParams.FLAG_FULLSCREEN);//full keran ile ilgili ayarlar setContentView(R.layout.activity_main); // flash switch button btnSwitch = (ImageButton) findViewById(R.id.buton); flashlight=(ImageButton)findViewById(R.id.flashlight); // First check if device is supporting flashlight or not hasFlash = getApplicationContext().getPackageManager() .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); // get the camera getCamera(); // displaying button image toggleButtonImage(); // Switch button click event to toggle flash on/off btnSwitch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isFlashOn) { // turn off flash turnOffFlash(); } else { // turn on flash turnOnFlash(); } } }); flashlight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent= new Intent(getBaseContext(),SpeakNow.class); startActivity(intent); } }); } // Get the camera private void getCamera() { if (camera == null) { try { camera = Camera.open(); params = camera.getParameters(); } catch (RuntimeException e) { } } } private void turnOnFlash() { if (!isFlashOn) { if (camera == null || params == null) { return; } params = camera.getParameters(); params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); camera.setParameters(params); camera.startPreview(); isFlashOn = true; toggleButtonImage(); } } private void turnOffFlash() { if (isFlashOn) { if (camera == null || params == null) { return; } params = camera.getParameters(); params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); camera.setParameters(params); camera.stopPreview(); isFlashOn = false; toggleButtonImage(); } } private void toggleButtonImage(){ if(isFlashOn){ btnSwitch.setImageResource(R.drawable.light_on); }else{ btnSwitch.setImageResource(R.drawable.light_off); } } @Override protected void onDestroy() { super.onDestroy(); } @Override protected void onPause() { super.onPause(); // on pause turn off the flash // turnOffFlash(); } @Override protected void onRestart() { super.onRestart(); } @Override protected void onResume() { super.onResume(); // on resume turn on the flash if(hasFlash) turnOnFlash(); } @Override protected void onStart() { super.onStart(); // on starting the app get the camera params getCamera(); } @Override public void onBackPressed() { // TODO Auto-generated method stub super.onBackPressed(); params = camera.getParameters(); params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); camera.setParameters(params); camera.stopPreview(); isFlashOn = false; if (camera != null) { camera.release(); camera = null; } Log.d("Camera","Back Pressed"); } @Override protected void onStop() { super.onStop(); // on stop release the camera // if (camera != null) { // camera.release(); // camera = null; // } } }