1
我打算寫一個hotWord應用程序與最新的API21和VoiceInteractionService,AlwaysOnHotwordDetector和VoiceInteractionSession。VoiceInteractionService API21 startSession錯誤
我已經創建了一個來電
startService(新意圖(MainActivity.this,MainInteractionService.class))的活動;
MainInteractionService:
public class MainInteractionService extends VoiceInteractionService
@Override
public void onCreate() {
super.onCreate();
ctx = getApplicationContext();
Log.d(TAG, "onCreate!!!!!!!!!! ");
onReady();
}
@Override
public void onReady() {
super.onReady();
Log.d(TAG, "onReady!!!!!!!!!! ");
Locale bLocale = new Locale("en", "US");
//hotwordDetector = createAlwaysOnHotwordDetector("Hello", bLocale, callback);
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "onStartCommand!!!!!!!!!! ");
//hotwordDetector.startRecognition(hotwordDetector.RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS);
Bundle args = new Bundle();
Log.d(TAG, "args: "+args);
startSession(args);
stopSelf(startId);
return START_NOT_STICKY;
}
**當onStartCommand被稱爲應用美眉和下面的日誌貓錯誤顯示:
來電不是當前的語音互動服務
有誰知道該怎麼辦? 我已經在任何地方搜索,但有這麼一點信息和示例關於這個API
的logcat:
Process: com.test5.simpleapphotword.simpleapphotword, PID: 29450
java.lang.RuntimeException: Unable to start service com[email protected]17c3e453 with Intent { cmp=com.test5.simpleapphotword.simpleapphotword/.MainInteractionService }: java.lang.SecurityException: Caller is not the current voice interaction service
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2881)
at android.app.ActivityThread.access$2100(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.SecurityException: Caller is not the current voice interaction service
at android.os.Parcel.readException(Parcel.java:1540)
at android.os.Parcel.readException(Parcel.java:1493)
at com.android.internal.app.IVoiceInteractionManagerService$Stub$Proxy.startSession(IVoiceInteractionManagerService.java:248)
at android.service.voice.VoiceInteractionService.startSession(VoiceInteractionService.java:143)
at com.test5.simpleapphotword.simpleapphotword.MainInteractionService.onStartCommand(MainInteractionService.java:78)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2864)
at android.app.ActivityThread.access$2100(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)