當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchableInfo類代碼示例

本文整理匯總了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);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:27,代碼來源:SuggestionsAdapter.java

示例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());
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:25,代碼來源:SearchView.java

示例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");
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:23,代碼來源:SearchView.java

示例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);
	}
}
 
開發者ID:ZalemSoftware,項目名稱:Ymir,代碼行數:23,代碼來源:ActivityBasedSearchableManager.java

示例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;
}
 
開發者ID:Qwaz,項目名稱:solved-hacking-problem,代碼行數:18,代碼來源:da.java

示例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());
}
 
開發者ID:GigigoGreenLabs,項目名稱:permissionsModule,代碼行數:27,代碼來源:SearchView.java

示例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");
    }
}
 
開發者ID:GigigoGreenLabs,項目名稱:permissionsModule,代碼行數:24,代碼來源:SearchView.java

示例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());
}
 
開發者ID:ivanovpv,項目名稱:darksms,代碼行數:25,代碼來源:SearchView.java

示例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);
				}
			});
		}
	}
}
 
開發者ID:nvllsvm,項目名稱:Audinaut,代碼行數:24,代碼來源:SubsonicFragment.java

示例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);
    }
 
開發者ID:iMeiji,項目名稱:Toutiao,代碼行數:21,代碼來源:SearchActivity.java

示例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;
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:22,代碼來源:SearchView.java

示例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;
}
 
開發者ID:MettaCenter,項目名稱:DailyMettaApp,代碼行數:21,代碼來源:ArticleActivityC.java

示例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);
    }
 
開發者ID:dannagle,項目名稱:PacketSender-Android,代碼行數:21,代碼來源:MainActivity.java

示例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);
    }
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:27,代碼來源:SearchViewActionBar.java

示例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);
    }
 
開發者ID:googlesamples,項目名稱:io2015-codelabs,代碼行數:23,代碼來源:SearchActivity.java


注:本文中的android.app.SearchableInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。