当前位置: 首页>>代码示例>>Java>>正文


Java SearchManager类代码示例

本文整理汇总了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) {
        }
    };
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:ChromeActivity.java

示例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;
}
 
开发者ID:Socialate,项目名称:furry-sniffle,代码行数:20,代码来源:MainActivity.java

示例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;
}
 
开发者ID:orionlee,项目名称:aDictOnCopy,代码行数:20,代码来源:DictionaryOnCopyService.java

示例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;
}
 
开发者ID:techstar-cloud,项目名称:techstar-org,代码行数:18,代码来源:MainActivity.java

示例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;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:29,代码来源:SearchWidgetProvider.java

示例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);
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:20,代码来源:QueryReceiverActivity.java

示例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);
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:21,代码来源:VoiceQueryReceiverActivity.java

示例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);
    }
}
 
开发者ID:Elbehiry,项目名称:Viajes,代码行数:20,代码来源:MainActivity.java

示例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);

    }
}
 
开发者ID:malah-code,项目名称:Open-Quran-Radio,代码行数:23,代码来源:MainActivity.java

示例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:
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:18,代码来源:SuggestionsAdapter.java

示例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);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:29,代码来源:SuggestionsAdapter.java

示例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;
}
 
开发者ID:cahergil,项目名称:Farmacias,代码行数:22,代码来源:DbProvider.java

示例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);
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:13,代码来源:AbsTagEditorActivity.java

示例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;
}
 
开发者ID:10clouds,项目名称:InifiniteRecyclerView,代码行数:19,代码来源:MainActivity.java

示例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);
    }
 
开发者ID:fantasy1022,项目名称:FancyTrendView,代码行数:32,代码来源:FancyTrendActivity.java


注:本文中的android.app.SearchManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。