Retrieve number of cameras instead of battery *charge counter*

This commit is contained in:
Benjamin Loison 2024-05-02 02:23:15 +02:00
parent d7e82d07c2
commit 34613e344b
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -4,8 +4,8 @@ import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.content.Context;
import android.os.BatteryManager;
import android.util.Log;
import android.hardware.camera2.CameraManager;
public class MainActivity extends Activity {
@Override
@ -15,9 +15,12 @@ public class MainActivity extends Activity {
TextView text = (TextView)findViewById(R.id.my_text);
Context context = getApplicationContext();
BatteryManager batteryManager = (BatteryManager)context.getSystemService(Context.BATTERY_SERVICE);
text.setText("Hello, worldg!" + batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER));
log("Hello from Camera app!");
log("Camera app initialized!");
try {
CameraManager cameraManager = (CameraManager)context.getSystemService(Context.CAMERA_SERVICE);
text.setText("Number of cameras: " + String.valueOf(cameraManager.getCameraIdList().length));
}
catch (Exception _e) {}
}
private void log(String toLog) {