0
簡而言之,我想創建一個android小部件,它可以在單擊它時讀出存儲在小部件中的地址。從AppWidgetProvider開始文本到語音
看了這個link的回答後,我在下面發佈了文字,我想知道它是否可以以類似的方式對文字進行文字處理。
// this intent points to activity that should handle results
Intent activityIntent = new Intent(context, ResultsActivity.class);
// this intent wraps results activity intent
PendingIntent resultsPendingIntent = PendingIntent.getActivity(context, 0, activityIntent, 0);
// this intent calls the speech recognition
Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech recognition demo");
voiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, resultsPendingIntent);
// this intent wraps voice recognition intent
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, voiceIntent, 0);
rv.setOnClickPendingIntent(R.id.btn, pendingIntent);
我想在AppWidgetProvider類中創建一個文本到語音的函數,但只看到了Actvity類中的文本到語音的示例,並且想知道是否可以在AppWidgetProvider類中執行它。看來,我將不得不爲widget創建TTS服務。感謝您的答案,雖然:) – consprice 2012-08-04 01:23:58