Browse Source

Refactor

bk_video
Bastian Kohler 1 year ago
parent
commit
e01e23eccd

+ 7
- 1
app/src/main/java/com/example/ueberwachungssystem/Detection/DetectorService.java View File



@ExperimentalGetImage @ExperimentalGetImage
public class DetectorService extends LifecycleService { public class DetectorService extends LifecycleService {

public ServiceBinder serviceBinder = new ServiceBinder(); public ServiceBinder serviceBinder = new ServiceBinder();
private DetectorService.OnDetectionListener listener; private DetectorService.OnDetectionListener listener;
private boolean isServiceRunning = false; private boolean isServiceRunning = false;
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
if (isServiceRunning) if (isServiceRunning)
return START_NOT_STICKY; return START_NOT_STICKY;


// Setup Service classes:
videoDetector = new VideoDetector(this); videoDetector = new VideoDetector(this);
videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() { videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
@Override @Override
passToServiceListener(detectionReport); passToServiceListener(detectionReport);
} }
}); });

audioRecorder = new AudioRecorder(this); audioRecorder = new AudioRecorder(this);



isServiceRunning = true; isServiceRunning = true;
return super.onStartCommand(intent, flags, startId); return super.onStartCommand(intent, flags, startId);
} }

+ 0
- 1
app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java View File



import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.ImageFormat; import android.graphics.ImageFormat;

+ 8
- 0
app/src/main/java/com/example/ueberwachungssystem/PermissionHandler.java View File

import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.widget.Toast;


import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
if (!hasPermissions()) if (!hasPermissions())
ActivityCompat.requestPermissions((Activity) context, permissions, PERMISSION_REQUEST_CODE); ActivityCompat.requestPermissions((Activity) context, permissions, PERMISSION_REQUEST_CODE);
} }

public void showPermissionToast() {
if (hasPermissions())
Toast.makeText(context, "permissions available", Toast.LENGTH_SHORT).show();
else
Toast.makeText(context, "permissions missing", Toast.LENGTH_SHORT).show();
}
} }

Loading…
Cancel
Save