我尝试运行此代码,但它说在 framworke.jar 中找不到某些东西
super.onCreate(savedInstanceState);
CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
String id = null;
try {
id = manager.getCameraIdList()[0];
} catch (CameraAccessException e) {
e.printStackTrace();
}
try {
manager.setTorchMode(id,true);
} catch (CameraAccessException e) {
e.printStackTrace();
}
但我得到了这个错误,
02-15 01:03:33.794 32378-32378/com.phenix.testcam E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.phenix.testcam, PID: 32378
java.lang.NoSuchMethodError: No virtual method setTorchMode(Ljava/lang/String;Z)V in class Landroid/hardware/camera2/CameraManager; or its super classes (declaration of 'android.hardware.camera2.CameraManager' appears in /system/framework/framework.jar)
at com.phenix.testcam.MainActivity.onCreate(MainActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5373)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
请问我需要一些解释