當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。