You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ai-catalog/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt
+4-21Lines changed: 4 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -83,20 +83,14 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe
83
83
}
84
84
85
85
@SuppressLint("MissingPermission")
86
-
funtoggleLiveSession(activity:Activity) {
86
+
funtoggleLiveSession() {
87
87
viewModelScope.launch {
88
88
if (liveSessionState.value isLiveSessionState.NotReady) return@launch
89
89
90
90
session?.let {
91
91
if (liveSessionState.value isLiveSessionState.Ready) {
92
-
if (ContextCompat.checkSelfPermission(
93
-
activity,
94
-
Manifest.permission.RECORD_AUDIO,
95
-
) ==PackageManager.PERMISSION_GRANTED
96
-
) {
97
-
it.startAudioConversation(::handleFunctionCall)
98
-
liveSessionState.value =LiveSessionState.Running
99
-
}
92
+
it.startAudioConversation(::handleFunctionCall)
93
+
liveSessionState.value =LiveSessionState.Running
100
94
} else {
101
95
it.stopAudioConversation()
102
96
liveSessionState.value =LiveSessionState.Ready
@@ -105,8 +99,7 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe
105
99
}
106
100
}
107
101
108
-
funinitializeGeminiLive(activity:Activity) {
109
-
requestAudioPermissionIfNeeded(activity)
102
+
funinitializeGeminiLive() {
110
103
viewModelScope.launch {
111
104
Log.d(TAG, "Start Gemini Live initialization")
112
105
val liveGenerationConfig = liveGenerationConfig {
@@ -233,14 +226,4 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe
0 commit comments