本文整理匯總了Java中android.app.SearchableInfo.getVoiceLanguageModeId方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchableInfo.getVoiceLanguageModeId方法的具體用法?Java SearchableInfo.getVoiceLanguageModeId怎麽用?Java SearchableInfo.getVoiceLanguageModeId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.SearchableInfo
的用法示例。
在下文中一共展示了SearchableInfo.getVoiceLanguageModeId方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createVoiceAppSearchIntent
import android.app.SearchableInfo; //導入方法依賴的package包/類
/**
* Create and return an Intent that can launch the voice search activity, perform a specific
* voice transcription, and forward the results to the searchable activity.
*
* @param baseIntent The voice app search intent to start from
* @return A completely-configured intent ready to send to the voice search activity
*/
private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) {
ComponentName searchActivity = searchable.getSearchActivity();
// create the necessary intent to set up a search-and-forward operation
// in the voice search system. We have to keep the bundle separate,
// because it becomes immutable once it enters the PendingIntent
Intent queryIntent = new Intent(Intent.ACTION_SEARCH);
queryIntent.setComponent(searchActivity);
PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent,
PendingIntent.FLAG_ONE_SHOT);
// Now set up the bundle that will be inserted into the pending intent
// when it's time to do the search. We always build it here (even if empty)
// because the voice search activity will always need to insert "QUERY" into
// it anyway.
Bundle queryExtras = new Bundle();
// Now build the intent to launch the voice search. Add all necessary
// extras to launch the voice recognizer, and then all the necessary extras
// to forward the results to the searchable activity
Intent voiceIntent = new Intent(baseIntent);
// Add all of the configuration options supplied by the searchable's metadata
String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM;
String prompt = null;
String language = null;
int maxResults = 1;
Resources resources = getResources();
if (searchable.getVoiceLanguageModeId() != 0) {
languageModel = resources.getString(searchable.getVoiceLanguageModeId());
}
if (searchable.getVoicePromptTextId() != 0) {
prompt = resources.getString(searchable.getVoicePromptTextId());
}
if (searchable.getVoiceLanguageId() != 0) {
language = resources.getString(searchable.getVoiceLanguageId());
}
if (searchable.getVoiceMaxResults() != 0) {
maxResults = searchable.getVoiceMaxResults();
}
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults);
voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
: searchActivity.flattenToShortString());
// Add the values that configure forwarding the results
voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending);
voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras);
return voiceIntent;
}
示例2: createVoiceAppSearchIntent
import android.app.SearchableInfo; //導入方法依賴的package包/類
@TargetApi(8)
private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) {
ComponentName searchActivity = searchable.getSearchActivity();
Intent queryIntent = new Intent("android.intent.action.SEARCH");
queryIntent.setComponent(searchActivity);
PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent, 1073741824);
Bundle queryExtras = new Bundle();
if (this.mAppSearchData != null) {
queryExtras.putParcelable("app_data", this.mAppSearchData);
}
Intent voiceIntent = new Intent(baseIntent);
String languageModel = "free_form";
String prompt = null;
String language = null;
int maxResults = 1;
if (VERSION.SDK_INT >= 8) {
Resources resources = getResources();
if (searchable.getVoiceLanguageModeId() != 0) {
languageModel = resources.getString(searchable.getVoiceLanguageModeId());
}
if (searchable.getVoicePromptTextId() != 0) {
prompt = resources.getString(searchable.getVoicePromptTextId());
}
if (searchable.getVoiceLanguageId() != 0) {
language = resources.getString(searchable.getVoiceLanguageId());
}
if (searchable.getVoiceMaxResults() != 0) {
maxResults = searchable.getVoiceMaxResults();
}
}
voiceIntent.putExtra("android.speech.extra.LANGUAGE_MODEL", languageModel);
voiceIntent.putExtra("android.speech.extra.PROMPT", prompt);
voiceIntent.putExtra("android.speech.extra.LANGUAGE", language);
voiceIntent.putExtra("android.speech.extra.MAX_RESULTS", maxResults);
voiceIntent.putExtra("calling_package", searchActivity == null ? null : searchActivity.flattenToShortString());
voiceIntent.putExtra("android.speech.extra.RESULTS_PENDINGINTENT", pending);
voiceIntent.putExtra("android.speech.extra.RESULTS_PENDINGINTENT_BUNDLE", queryExtras);
return voiceIntent;
}
示例3: createVoiceAppSearchIntent
import android.app.SearchableInfo; //導入方法依賴的package包/類
/**
* Create and return an Intent that can launch the voice search activity, perform a specific
* voice transcription, and forward the results to the searchable activity.
*
* @param baseIntent The voice app search intent to start from
* @return A completely-configured intent ready to send to the voice search activity
*/
@TargetApi(Build.VERSION_CODES.FROYO)
private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) {
ComponentName searchActivity = searchable.getSearchActivity();
// create the necessary intent to set up a search-and-forward operation
// in the voice search system. We have to keep the bundle separate,
// because it becomes immutable once it enters the PendingIntent
Intent queryIntent = new Intent(Intent.ACTION_SEARCH);
queryIntent.setComponent(searchActivity);
PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent,
PendingIntent.FLAG_ONE_SHOT);
// Now set up the bundle that will be inserted into the pending intent
// when it's time to do the search. We always build it here (even if empty)
// because the voice search activity will always need to insert "QUERY" into
// it anyway.
Bundle queryExtras = new Bundle();
if (mAppSearchData != null) {
queryExtras.putParcelable(SearchManager.APP_DATA, mAppSearchData);
}
// Now build the intent to launch the voice search. Add all necessary
// extras to launch the voice recognizer, and then all the necessary extras
// to forward the results to the searchable activity
Intent voiceIntent = new Intent(baseIntent);
// Add all of the configuration options supplied by the searchable's metadata
String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM;
String prompt = null;
String language = null;
int maxResults = 1;
if (Build.VERSION.SDK_INT >= 8) {
Resources resources = getResources();
if (searchable.getVoiceLanguageModeId() != 0) {
languageModel = resources.getString(searchable.getVoiceLanguageModeId());
}
if (searchable.getVoicePromptTextId() != 0) {
prompt = resources.getString(searchable.getVoicePromptTextId());
}
if (searchable.getVoiceLanguageId() != 0) {
language = resources.getString(searchable.getVoiceLanguageId());
}
if (searchable.getVoiceMaxResults() != 0) {
maxResults = searchable.getVoiceMaxResults();
}
}
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults);
voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
: searchActivity.flattenToShortString());
// Add the values that configure forwarding the results
voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending);
voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras);
return voiceIntent;
}
示例4: createVoiceAppSearchIntent
import android.app.SearchableInfo; //導入方法依賴的package包/類
@TargetApi(8)
private Intent createVoiceAppSearchIntent(Intent paramIntent, SearchableInfo paramSearchableInfo)
{
ComponentName localComponentName = paramSearchableInfo.getSearchActivity();
Intent localIntent1 = new Intent("android.intent.action.SEARCH");
localIntent1.setComponent(localComponentName);
PendingIntent localPendingIntent = PendingIntent.getActivity(getContext(), 0, localIntent1, 1073741824);
Bundle localBundle = new Bundle();
if (this.mAppSearchData != null) {
localBundle.putParcelable("app_data", this.mAppSearchData);
}
Intent localIntent2 = new Intent(paramIntent);
String str1 = "free_form";
int i = 1;
int j = Build.VERSION.SDK_INT;
String str2 = null;
String str3 = null;
if (j >= 8)
{
Resources localResources = getResources();
if (paramSearchableInfo.getVoiceLanguageModeId() != 0) {
str1 = localResources.getString(paramSearchableInfo.getVoiceLanguageModeId());
}
int k = paramSearchableInfo.getVoicePromptTextId();
str3 = null;
if (k != 0) {
str3 = localResources.getString(paramSearchableInfo.getVoicePromptTextId());
}
int m = paramSearchableInfo.getVoiceLanguageId();
str2 = null;
if (m != 0) {
str2 = localResources.getString(paramSearchableInfo.getVoiceLanguageId());
}
if (paramSearchableInfo.getVoiceMaxResults() != 0) {
i = paramSearchableInfo.getVoiceMaxResults();
}
}
localIntent2.putExtra("android.speech.extra.LANGUAGE_MODEL", str1);
localIntent2.putExtra("android.speech.extra.PROMPT", str3);
localIntent2.putExtra("android.speech.extra.LANGUAGE", str2);
localIntent2.putExtra("android.speech.extra.MAX_RESULTS", i);
if (localComponentName == null) {}
for (String str4 = null;; str4 = localComponentName.flattenToShortString())
{
localIntent2.putExtra("calling_package", str4);
localIntent2.putExtra("android.speech.extra.RESULTS_PENDINGINTENT", localPendingIntent);
localIntent2.putExtra("android.speech.extra.RESULTS_PENDINGINTENT_BUNDLE", localBundle);
return localIntent2;
}
}
示例5: createVoiceAppSearchIntent
import android.app.SearchableInfo; //導入方法依賴的package包/類
private Intent createVoiceAppSearchIntent(Intent intent, SearchableInfo searchableinfo)
{
ComponentName componentname = searchableinfo.getSearchActivity();
Object obj = new Intent("android.intent.action.SEARCH");
((Intent) (obj)).setComponent(componentname);
PendingIntent pendingintent = PendingIntent.getActivity(getContext(), 0, ((Intent) (obj)), 0x40000000);
Bundle bundle = new Bundle();
if (mAppSearchData != null)
{
bundle.putParcelable("app_data", mAppSearchData);
}
Intent intent2 = new Intent(intent);
intent = "free_form";
String s1 = null;
obj = null;
Object obj1 = null;
String s = null;
boolean flag = true;
Intent intent1 = intent;
int i = ((flag) ? 1 : 0);
if (android.os.Build.VERSION.SDK_INT >= 8)
{
obj1 = getResources();
if (searchableinfo.getVoiceLanguageModeId() != 0)
{
intent = ((Resources) (obj1)).getString(searchableinfo.getVoiceLanguageModeId());
}
if (searchableinfo.getVoicePromptTextId() != 0)
{
obj = ((Resources) (obj1)).getString(searchableinfo.getVoicePromptTextId());
}
if (searchableinfo.getVoiceLanguageId() != 0)
{
s = ((Resources) (obj1)).getString(searchableinfo.getVoiceLanguageId());
}
obj1 = s;
intent1 = intent;
i = ((flag) ? 1 : 0);
s1 = ((String) (obj));
if (searchableinfo.getVoiceMaxResults() != 0)
{
i = searchableinfo.getVoiceMaxResults();
s1 = ((String) (obj));
intent1 = intent;
obj1 = s;
}
}
intent2.putExtra("android.speech.extra.LANGUAGE_MODEL", intent1);
intent2.putExtra("android.speech.extra.PROMPT", s1);
intent2.putExtra("android.speech.extra.LANGUAGE", ((String) (obj1)));
intent2.putExtra("android.speech.extra.MAX_RESULTS", i);
if (componentname == null)
{
intent = null;
} else
{
intent = componentname.flattenToShortString();
}
intent2.putExtra("calling_package", intent);
intent2.putExtra("android.speech.extra.RESULTS_PENDINGINTENT", pendingintent);
intent2.putExtra("android.speech.extra.RESULTS_PENDINGINTENT_BUNDLE", bundle);
return intent2;
}