From 34613e344b717f979c3c77978ea0fa1c30fb041e Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Thu, 2 May 2024 02:23:15 +0200 Subject: [PATCH] Retrieve number of cameras instead of battery *charge counter* --- .../camera/MainActivity.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/datasets/android/java/com/robust_image_source_identification_on_modern_smartphones/camera/MainActivity.java b/datasets/android/java/com/robust_image_source_identification_on_modern_smartphones/camera/MainActivity.java index ce735a1..2f7e4be 100644 --- a/datasets/android/java/com/robust_image_source_identification_on_modern_smartphones/camera/MainActivity.java +++ b/datasets/android/java/com/robust_image_source_identification_on_modern_smartphones/camera/MainActivity.java @@ -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) {