feat(service): 增强 VoiceInteraction 服务与界面解析
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package com.ttstd.dialer.service;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.service.voice.VoiceInteractionService;
|
||||
import android.service.voice.VoiceInteractionSession;
|
||||
|
||||
import com.ttstd.dialer.utils.Logger;
|
||||
|
||||
@@ -12,4 +15,28 @@ public class MyVoiceInteractionService extends VoiceInteractionService {
|
||||
super.onCreate();
|
||||
Logger.d(TAG, "onCreate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady() {
|
||||
super.onReady();
|
||||
Logger.d(TAG, "onReady");
|
||||
// 服务准备就绪,通常在此之后可以开启 Session 获取界面信息
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Logger.d(TAG, "onStartCommand: action=" + (intent != null ? intent.getAction() : "null"));
|
||||
// 如果需要主动触发获取界面信息,可以调用 showSession
|
||||
// 这会触发 MyVoiceInteractionSessionService 创建 Session,并回调 onHandleAssist
|
||||
if (intent != null && "ACTION_SHOW_SESSION".equals(intent.getAction())) {
|
||||
showSession(new Bundle(), VoiceInteractionSession.SHOW_WITH_ASSIST | VoiceInteractionSession.SHOW_WITH_SCREENSHOT);
|
||||
}
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShutdown() {
|
||||
super.onShutdown();
|
||||
Logger.d(TAG, "onShutdown");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user