I have read every single other post on this specific error, and this still does not make sense to me, at all.
So far I have tried:
import android.hardware.camera2.CameraManager;
public class HelloWorld {
public int getcameracount() {
try {
return CameraManager.getCameraIdList().length;
} finally {
}
}
public void main(String[] args) {
System.out.println("number of cameras: " + getcameracount());
}
}
And
import android.hardware.camera2.CameraManager;
public class HelloWorld {
public void main(String[] args) {
new cameraids list1;
System.out.println("number of cameras: " + list1.CameraIDList.length);
}
}
class cameraids {
public String[] CameraIDList = CameraManager.getCameraIdList();
}
And
import android.hardware.camera2.CameraManager;
public class HelloWorld {
public void main(String[] args) {
cameraids list1 = new cameraids();
System.out.println("number of cameras: " + list1.CameraIDList.length);
}
}
class cameraids {
public String[] CameraIDList = CameraManager.getCameraIdList();
}
And many, many others.
Without exception, I get
1. ERROR in /storage/emulated/0/redacted/redacted/src/HelloWorld.java (at line 19)
String[] CameraIDList = CameraManager.getCameraIdList();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Cannot make a static reference to the non-static method getCameraIdList() from the type CameraManager
As an error. Only the line number changes per attempt.
I've also looked at various code examples, and they all use some variation of
String[] idlist = manager.getCameraIdList();
Where idlist is any variable name, and manager is any variant of manager, Cmanager, or CameraManager depending on that example's author's setup. Mine is CameraManager.
The examples all seem to 'just work' for their respective authors.
I don't know what I'm doing differently. I know some assembly, C++, M and G code, basic etc, and they all seem really straightforward by comparison. Why can't I just print a number?
P.S. the filepath is redacted because it contained lots of swearing