Skip to content

Commit 9ba3d38

Browse files
authored
Add cleanup methods for detection pipeline
1 parent 22de257 commit 9ba3d38

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

Yolo/android/app/src/main/java/com/example/executorchyolodemo/BirdDetectionActivity.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,30 @@ protected void onCreate(Bundle savedInstanceState) {
9797
}
9898
}
9999

100+
@Override
101+
protected void onDestroy() {
102+
super.onDestroy();
103+
104+
// Clean up the detection pipeline
105+
if (detectionPipeline != null) {
106+
detectionPipeline.close();
107+
detectionPipeline = null;
108+
}
109+
110+
Log.d(TAG, "BirdDetectionActivity destroyed");
111+
}
112+
113+
@Override
114+
protected void onPause() {
115+
super.onPause();
116+
117+
// Optional: Release resources when app goes to background
118+
if (detectionPipeline != null) {
119+
detectionPipeline.close();
120+
detectionPipeline = null;
121+
}
122+
}
123+
100124
private void initializeViews() {
101125
previewView = findViewById(R.id.previewView);
102126
overlayImageView = findViewById(R.id.overlayImageView);
@@ -432,4 +456,4 @@ protected void onResume() {
432456
super.onResume();
433457
updateSessionUI();
434458
}
435-
}
459+
}

0 commit comments

Comments
 (0)