本文整理匯總了Java中android.app.SearchableInfo類的典型用法代碼示例。如果您正苦於以下問題:Java SearchableInfo類的具體用法?Java SearchableInfo怎麽用?Java SearchableInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SearchableInfo類屬於android.app包,在下文中一共展示了SearchableInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSearchManagerSuggestions
import android.app.SearchableInfo; //導入依賴的package包/類
Cursor getSearchManagerSuggestions(SearchableInfo searchable, String query, int limit) {
if (searchable == null) {
return null;
}
String authority = searchable.getSuggestAuthority();
if (authority == null) {
return null;
}
Builder uriBuilder = new Builder().scheme(Utils.RESPONSE_CONTENT).authority(authority).query("").fragment("");
String contentPath = searchable.getSuggestPath();
if (contentPath != null) {
uriBuilder.appendEncodedPath(contentPath);
}
uriBuilder.appendPath("search_suggest_query");
String selection = searchable.getSuggestSelection();
String[] selArgs = null;
if (selection != null) {
selArgs = new String[]{query};
} else {
uriBuilder.appendPath(query);
}
if (limit > 0) {
uriBuilder.appendQueryParameter("limit", String.valueOf(limit));
}
return this.mContext.getContentResolver().query(uriBuilder.build(), null, selection, selArgs, null);
}
示例2: setSearchableInfo
import android.app.SearchableInfo; //導入依賴的package包/類
/**
* Sets the SearchableInfo for this SearchView. Properties in the SearchableInfo are used
* to display labels, hints, suggestions, create intents for launching search results screens
* and controlling other affordances such as a voice button.
*
* @param searchable a SearchableInfo can be retrieved from the SearchManager, for a specific
* activity or a global search provider.
*/
public void setSearchableInfo(SearchableInfo searchable) {
mSearchable = searchable;
if (mSearchable != null) {
updateSearchAutoComplete();
updateQueryHint();
}
// Cache the voice search capability
mVoiceButtonEnabled = hasVoiceSearch();
if (mVoiceButtonEnabled) {
// Disable the microphone on the keyboard, as a mic is displayed near the text box
// TODO: use imeOptions to disable voice input when the new API will be available
mQueryTextView.setPrivateImeOptions(IME_OPTION_NO_MICROPHONE);
}
updateViewsVisibility(isIconified());
}
示例3: onVoiceClicked
import android.app.SearchableInfo; //導入依賴的package包/類
private void onVoiceClicked() {
// guard against possible race conditions
if (mSearchable == null) {
return;
}
SearchableInfo searchable = mSearchable;
try {
if (searchable.getVoiceSearchLaunchWebSearch()) {
Intent webSearchIntent = createVoiceWebSearchIntent(mVoiceWebSearchIntent,
searchable);
getContext().startActivity(webSearchIntent);
} else if (searchable.getVoiceSearchLaunchRecognizer()) {
Intent appSearchIntent = createVoiceAppSearchIntent(mVoiceAppSearchIntent,
searchable);
getContext().startActivity(appSearchIntent);
}
} catch (ActivityNotFoundException e) {
// Should not happen, since we check the availability of
// voice search before showing the button. But just in case...
Log.w(LOG_TAG, "Could not find voice search activity");
}
}
示例4: ActivityBasedSearchableManager
import android.app.SearchableInfo; //導入依賴的package包/類
public ActivityBasedSearchableManager(Context context, Map<String, String> searchablesConfigs) {
searchables = new HashMap<>(searchablesConfigs.size());
SearchManager searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
for (Entry<String, String> entry : searchablesConfigs.entrySet()) {
String entityName = entry.getKey();
String activityName = entry.getValue();
//Se não possui o pacote, tem que colocar o pacote da aplicação.
if (activityName.startsWith(".")) {
activityName = context.getApplicationInfo().packageName + activityName;
}
ComponentName componentName = new ComponentName(context, activityName);
SearchableInfo searchableInfo = searchManager.getSearchableInfo(componentName);
if (searchableInfo == null) {
throw new IllegalArgumentException("Searchable not found for " + activityName);
}
searchables.put(entityName, searchableInfo);
}
}
示例5: da
import android.app.SearchableInfo; //導入依賴的package包/類
public da(Context context, SearchView searchView, SearchableInfo searchableInfo, WeakHashMap weakHashMap) {
super(context, searchView.getSuggestionRowLayout(), null, true);
this.f1490p = false;
this.f1491q = 1;
this.f1493s = -1;
this.f1494t = -1;
this.f1495u = -1;
this.f1496v = -1;
this.f1497w = -1;
this.f1498x = -1;
this.f1484j = (SearchManager) this.d.getSystemService("search");
this.f1485k = searchView;
this.f1486l = searchableInfo;
this.f1489o = searchView.getSuggestionCommitIconResId();
this.f1487m = context;
this.f1488n = weakHashMap;
}
示例6: setSearchableInfo
import android.app.SearchableInfo; //導入依賴的package包/類
/**
* Sets the SearchableInfo for this SearchView. Properties in the SearchableInfo are used
* to display labels, hints, suggestions, create intents for launching search results screens
* and controlling other affordances such as a voice button.
*
* @param searchable a SearchableInfo can be retrieved from the SearchManager, for a specific
* activity or a global search provider.
*/
public void setSearchableInfo(SearchableInfo searchable) {
mSearchable = searchable;
if (mSearchable != null) {
if (IS_AT_LEAST_FROYO) {
updateSearchAutoComplete();
}
updateQueryHint();
}
// Cache the voice search capability
mVoiceButtonEnabled = IS_AT_LEAST_FROYO && hasVoiceSearch();
if (mVoiceButtonEnabled) {
// Disable the microphone on the keyboard, as a mic is displayed near the text box
// TODO: use imeOptions to disable voice input when the new API will be available
mSearchSrcTextView.setPrivateImeOptions(IME_OPTION_NO_MICROPHONE);
}
updateViewsVisibility(isIconified());
}
示例7: onVoiceClicked
import android.app.SearchableInfo; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.FROYO)
private void onVoiceClicked() {
// guard against possible race conditions
if (mSearchable == null) {
return;
}
SearchableInfo searchable = mSearchable;
try {
if (searchable.getVoiceSearchLaunchWebSearch()) {
Intent webSearchIntent = createVoiceWebSearchIntent(mVoiceWebSearchIntent,
searchable);
getContext().startActivity(webSearchIntent);
} else if (searchable.getVoiceSearchLaunchRecognizer()) {
Intent appSearchIntent = createVoiceAppSearchIntent(mVoiceAppSearchIntent,
searchable);
getContext().startActivity(appSearchIntent);
}
} catch (ActivityNotFoundException e) {
// Should not happen, since we check the availability of
// voice search before showing the button. But just in case...
Log.w(LOG_TAG, "Could not find voice search activity");
}
}
示例8: setSearchableInfo
import android.app.SearchableInfo; //導入依賴的package包/類
/**
* Sets the SearchableInfo for this SearchView. Properties in the SearchableInfo are used
* to display labels, hints, suggestions, create intents for launching search results screens
* and controlling other affordances such as a voice button.
*
* @param searchable a SearchableInfo can be retrieved from the SearchManager, for a specific
* activity or a global search provider.
*/
public void setSearchableInfo(SearchableInfo searchable) {
mSearchable = searchable;
if (mSearchable != null) {
updateSearchAutoComplete();
updateQueryHint();
}
// Cache the voice search capability
mVoiceButtonEnabled = hasVoiceSearch();
if (mVoiceButtonEnabled) {
// Disable the microphone on the keyboard, as a mic is displayed near the text box
// TODO: use imeOptions to disable voice input when the new API will be available
mQueryTextView.setPrivateImeOptions(IME_OPTION_NO_MICROPHONE);
}
updateViewsVisibility(isIconified());
}
示例9: onFinishSetupOptionsMenu
import android.app.SearchableInfo; //導入依賴的package包/類
protected void onFinishSetupOptionsMenu(final Menu menu) {
searchItem = menu.findItem(R.id.menu_global_search);
if(searchItem != null) {
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
SearchManager searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
SearchableInfo searchableInfo = searchManager.getSearchableInfo(context.getComponentName());
if(searchableInfo == null) {
Log.w(TAG, "Failed to get SearchableInfo");
} else {
searchView.setSearchableInfo(searchableInfo);
}
String currentQuery = getCurrentQuery();
if(currentQuery != null) {
searchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
searchView.setQuery(getCurrentQuery(), false);
}
});
}
}
}
示例10: onCreateOptionsMenu
import android.app.SearchableInfo; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
MenuItem item = menu.findItem(R.id.action_search);
searchView = (SearchView) MenuItemCompat.getActionView(item);
// 關聯檢索配置與 SearchActivity
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchableInfo searchableInfo = searchManager.getSearchableInfo(
new ComponentName(getApplicationContext(), SearchActivity.class));
searchView.setSearchableInfo(searchableInfo);
searchView.onActionViewExpanded();
// // 設置搜索文字樣式
// EditText searchEditText = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
// searchEditText.setTextColor(getResources().getColor(R.color.textColorPrimary));
// searchEditText.setHintTextColor(getResources().getColor(R.color.textColorPrimary));
// searchEditText.setBackgroundColor(Color.WHITE);
setOnQuenyTextChangeListener();
return super.onCreateOptionsMenu(menu);
}
示例11: setSearchableInfo
import android.app.SearchableInfo; //導入依賴的package包/類
public void setSearchableInfo(SearchableInfo paramSearchableInfo)
{
this.mSearchable = paramSearchableInfo;
if (this.mSearchable != null)
{
if (IS_AT_LEAST_FROYO) {
updateSearchAutoComplete();
}
updateQueryHint();
}
if ((IS_AT_LEAST_FROYO) && (hasVoiceSearch())) {}
for (boolean bool = true;; bool = false)
{
this.mVoiceButtonEnabled = bool;
if (this.mVoiceButtonEnabled) {
this.mSearchSrcTextView.setPrivateImeOptions("nm");
}
updateViewsVisibility(isIconified());
return;
}
}
示例12: onCreateOptionsMenu
import android.app.SearchableInfo; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu iMenu) {
//Inflating the menu (which will add items to the action bar)
getMenuInflater().inflate(R.menu.menu_article, iMenu);
//Setting up the SearchView
SearchManager tSearchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
SearchView tSearchView = (SearchView) iMenu.findItem(R.id.action_text_search).getActionView();
ComponentName tComponentName = this.getComponentName();
SearchableInfo tSearchableInfo = tSearchManager.getSearchableInfo(tComponentName);
tSearchView.setSearchableInfo(tSearchableInfo);
tSearchView.setIconifiedByDefault(false);
if(BuildConfig.DEBUG == false){
MenuItem tMenuItem = iMenu.findItem(R.id.action_debug_download);
tMenuItem.setVisible(false);
}
return true;
}
示例13: setupSearchView
import android.app.SearchableInfo; //導入依賴的package包/類
private void setupSearchView(MenuItem searchItem) {
//searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null
&& inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
mSearchView.setSearchableInfo(info);
}
mSearchView.setOnQueryTextListener(this);
}
示例14: setupSearchView
import android.app.SearchableInfo; //導入依賴的package包/類
private void setupSearchView(MenuItem searchItem) {
if (isAlwaysExpanded()) {
mSearchView.setIconifiedByDefault(false);
} else {
searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
}
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
// Try to use the "applications" global search provider
SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null
&& inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
mSearchView.setSearchableInfo(info);
}
mSearchView.setOnQueryTextListener(this);
}
示例15: setupSearchView
import android.app.SearchableInfo; //導入依賴的package包/類
private void setupSearchView(MenuItem searchItem) {
mSearchView.setIconifiedByDefault(false);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null
&& inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
mSearchView.setSearchableInfo(info);
}
mSearchView.setOnQueryTextListener(this);
mSearchView.setFocusable(false);
mSearchView.setFocusableInTouchMode(false);
}