本文整理匯總了Java中android.app.SearchManager類的典型用法代碼示例。如果您正苦於以下問題:Java SearchManager類的具體用法?Java SearchManager怎麽用?Java SearchManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SearchManager類屬於android.app包,在下文中一共展示了SearchManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createIntentHandlerDelegate
import android.app.SearchManager; //導入依賴的package包/類
protected IntentHandlerDelegate createIntentHandlerDelegate() {
return new IntentHandlerDelegate() {
@Override
public void processWebSearchIntent(String query) {
Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
searchIntent.putExtra(SearchManager.QUERY, query);
startActivity(searchIntent);
}
@Override
public void processUrlViewIntent(String url, String referer, String headers,
TabOpenType tabOpenType, String externalAppId, int tabIdToBringToFront,
boolean hasUserGesture, Intent intent) {
}
};
}
示例2: onCreateOptionsMenu
import android.app.SearchManager; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search_btn).getActionView();
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
searchView.setMaxWidth(Integer.MAX_VALUE);
searchView.requestFocus(1);
//searchView.setSubmitButtonEnabled(true);
return true;
}
示例3: intentForDictionary
import android.app.SearchManager; //導入依賴的package包/類
private Intent intentForDictionary(CharSequence word) {
final SettingsModel settings = new SettingsModel(this);
String dictPkg = settings.getPackageName();
String action = settings.getAction();
if (dictPkg != null && dictPkg.startsWith("livio.pack.lang.") && !Intent.ACTION_SEARCH.equals(action)) {
PLog.v("DictionaryOnCopyService.launchDictionary(): Livio-specific workaround for action. package=%s", dictPkg);
// Livio dictionaries support colordict's action, but somehow it only brings up the app without word lookup.
// So here I use Livio's default action string
action = Intent.ACTION_SEARCH;
}
Intent intent = new Intent(action);
intent.setPackage(dictPkg);
intent.putExtra(SearchManager.QUERY, word);
// FLAG_ACTIVITY_NO_USER_ACTION is needed to make system back button work, i.e.,
// after dictionary is launched, pressing back button will go back to the previous app.
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
return intent;
}
示例4: onCreateOptionsMenu
import android.app.SearchManager; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.nav, menu);
SearchManager searchManager = (SearchManager)
getSystemService(Context.SEARCH_SERVICE);
searchMenuItem = menu.findItem(R.id.action_search);
searchView = (SearchView) searchMenuItem.getActionView();
searchView.setSearchableInfo(searchManager.
getSearchableInfo(getComponentName()));
searchView.setSubmitButtonEnabled(true);
return true;
}
示例5: get
import android.app.SearchManager; //導入依賴的package包/類
/**
* - * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}
* - * provided by the same package which is set to be global search activity.
* - * If widgetCategory is not supported, or no such widget is found, returns the first widget
* - * provided by the package.
* -
*/
public static AppWidgetProviderInfo get(Context context) {
SearchManager searchManager =
(SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
ComponentName searchComponent = searchManager.getGlobalSearchActivity();
if (searchComponent == null) return null;
String providerPkg = searchComponent.getPackageName();
AppWidgetProviderInfo defaultWidgetForSearchPackage = null;
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) {
if (info.provider.getPackageName().equals(providerPkg) && info.configure == null) {
if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) {
return info;
} else if (defaultWidgetForSearchPackage == null) {
defaultWidgetForSearchPackage = info;
}
}
}
return defaultWidgetForSearchPackage;
}
示例6: onCreate
import android.app.SearchManager; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
String query = getIntent().getStringExtra(SearchManager.QUERY);
if (query != null)
{
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(query, null);
Intent intent = new Intent(QueryReceiverActivity.this, SearchActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_QUERY, query);
startActivityForResultWithoutTransition(QueryReceiverActivity.this, intent);
}
finish();
Util.disablePendingTransition(this);
}
示例7: onCreate
import android.app.SearchManager; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
String query = getIntent().getStringExtra(SearchManager.QUERY);
if (query != null)
{
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(query, null);
Intent intent = new Intent(VoiceQueryReceiverActivity.this, SearchActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_QUERY, query);
intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
startActivityForResultWithoutTransition(VoiceQueryReceiverActivity.this, intent);
}
finish();
Util.disablePendingTransition(this);
}
示例8: updateSearchSuggestion
import android.app.SearchManager; //導入依賴的package包/類
private void updateSearchSuggestion(String query) {
// cursor
ContentResolver contentResolver = getApplicationContext().getContentResolver();
String contentUri = "content://" + MySearchRecentSuggestions.AUTHORITY + '/' + SearchManager.SUGGEST_URI_PATH_QUERY;
Uri uri = Uri.parse(contentUri);
Cursor cursor = contentResolver.query(uri, null, null, new String[]{query}, null);
// searchview content
if (mSearchSuggestionAdapter == null) {
// create adapter
mSearchSuggestionAdapter = new SearchSuggestionAdapter(MainActivity.this, cursor);
// set adapter
mSearchView.setSuggestionsAdapter(mSearchSuggestionAdapter);
} else {
// refill adapter
mSearchSuggestionAdapter.refill(MainActivity.this, cursor);
// set adapter
mSearchView.setSuggestionsAdapter(mSearchSuggestionAdapter);
}
}
示例9: onCreateOptionsMenu
import android.app.SearchManager; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
try {
// inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main_actionbar, menu);
// Associate searchable configuration with the SearchView
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView =
(SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setSearchableInfo(
searchManager.getSearchableInfo(getComponentName()));
}catch(Exception ex){
LogHelper.e(LOG_TAG, ex.getMessage());
}finally {
return super.onCreateOptionsMenu(menu);
}
}
示例10: updateSpinnerState
import android.app.SearchManager; //導入依賴的package包/類
private void updateSpinnerState(Cursor cursor) {
Bundle extras = cursor != null ? cursor.getExtras() : null;
if (DBG) {
Log.d(LOG_TAG, "updateSpinnerState - extra = "
+ (extras != null
? extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)
: null));
}
// Check if the Cursor indicates that the query is not complete and show the spinner
if (extras != null
&& extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)) {
// mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
return;
}
// If cursor is null or is done, stop the spinner
// mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
}
示例11: changeCursor
import android.app.SearchManager; //導入依賴的package包/類
/**
* Cache columns.
*/
@Override
public void changeCursor(Cursor c) {
if (DBG) Log.d(LOG_TAG, "changeCursor(" + c + ")");
if (mClosed) {
Log.w(LOG_TAG, "Tried to change cursor after adapter was closed.");
if (c != null) c.close();
return;
}
try {
super.changeCursor(c);
if (c != null) {
mText1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1);
mText2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2);
mText2UrlCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2_URL);
mIconName1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1);
mIconName2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2);
mFlagsCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_FLAGS);
}
} catch (Exception e) {
Log.e(LOG_TAG, "error changing cursor and caching columns", e);
}
}
示例12: createMatrixCursor
import android.app.SearchManager; //導入依賴的package包/類
private MatrixCursor createMatrixCursor(Cursor cursor, int cursorOrigin) {
MatrixCursor matrixCursor = new MatrixCursor(suggestionsColumnNames, cursor.getCount());
MatrixCursor.RowBuilder builder;
if (cursor.moveToFirst()) {
do {
builder = matrixCursor.newRow();
if (cursorOrigin == RECENT_SEARCH_ORIGIN) {
builder.add(FindQuickSearchAdapter.HISTORY_ROW);
builder.add(cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_QUERY)));
} else {
builder.add(FindQuickSearchAdapter.DATABASE_ROW);
builder.add(cursor.getString(cursor.getColumnIndex(DbContract.FarmaciasEntity.NAME)));
}
} while (cursor.moveToNext());
}
cursor.close();
return matrixCursor;
}
示例13: searchWebFor
import android.app.SearchManager; //導入依賴的package包/類
protected void searchWebFor(String... keys) {
StringBuilder stringBuilder = new StringBuilder();
for (String key : keys) {
stringBuilder.append(key);
stringBuilder.append(" ");
}
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY, stringBuilder.toString());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
示例14: onCreateOptionsMenu
import android.app.SearchManager; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the options menu from XML
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
SearchManager searchManager = (SearchManager)
getSystemService(Context.SEARCH_SERVICE);
MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setSearchableInfo(searchManager.
getSearchableInfo(getComponentName()));
searchView.setOnQueryTextListener(this);
MenuItemCompat.setOnActionExpandListener(searchMenuItem, this);
return true;
}
示例15: setUpRecyclerView
import android.app.SearchManager; //導入依賴的package包/類
private void setUpRecyclerView() {
googleTrendAdapter = new FancyTrendAdapter(this, trendItemList, Constant.DEFAULT_ROW_NUMBER, new FancyTrendAdapter.OnItemClickListener() {
@Override
public void onItemClick(View v, String trend, int position) {
if (!mVisible) {
FancyTrendActivity.this.toggle();
FancyTrendActivity.this.delayedHide(AUTO_HIDE_DELAY_MILLIS);
} else {
if (fancyTrendPresenter.getClickBehavior() == SPUtils.ClickBehaviorItem.googleSearch) {
//TODO:Use chrome tab to implement
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY, trend);
startActivity(intent);
} else if (fancyTrendPresenter.getClickBehavior() == SPUtils.ClickBehaviorItem.singlecountry) {
new MaterialDialog.Builder(FancyTrendActivity.this)
.title(R.string.choose_country)
.items(R.array.trend_country_name)
.itemsCallback((dialog, view, which, text) -> {
String code = Constant.getCountryCode(String.valueOf(text));
fancyTrendPresenter.retrieveSingleTrend(code, position);
})
.show();
}
}
}
});
trendRecycleView.setLayoutManager(new CustomGridLayoutManager(this, Constant.DEFAULT_COLUMN_NUMBER));
trendRecycleView.setAdapter(googleTrendAdapter);
trendRecycleView.setHasFixedSize(true);
}