Skip to content

Commit 523a9a3

Browse files
feat: Conditionally show 'AI stopped' toast
The 'The AI stopped Screen Operator' toast is now only displayed if: - 'takeScreenshot()' is not in the AI message (case-insensitive). - AND the PhotoReasoning screen is not visible. To check if the app is in the foreground, the ActivityManager is used to analyze running processes. This is a standard Android method to determine the foreground status without requiring additional flags or lifecycle changes in other files. Fixes unresolved reference to receiverContext.
1 parent d904b41 commit 523a9a3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningViewModel.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ class PhotoReasoningViewModel(
134134
val errorMessage = intent.getStringExtra(ScreenCaptureService.EXTRA_AI_ERROR_MESSAGE)
135135

136136
if (responseText != null) {
137+
if (context == null) {
138+
Log.e(TAG, "Context null in receiver, cannot show toast")
139+
return
140+
}
141+
val receiverContext = context
137142
Log.d(TAG, "AI Call Success via Broadcast: $responseText")
138143
_uiState.value = PhotoReasoningUiState.Success(responseText)
139144
updateAiMessage(responseText) // Existing method to update chat history

0 commit comments

Comments
 (0)