Android SearchableInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SearchableInfo class.

This code example shows how to use the following methods:getSearchActivity, getVoiceLanguageId, getVoiceLanguageModeId, getVoiceMaxResults, getVoicePromptTextId
     * This code is copied from SearchDialog 
     * 
     * @return A completely-configured intent ready to send to the voice search activity 
     */ 
    private Intent createVoiceAppSearchIntent(Bundle appData) {
        ComponentName searchActivity = mSearchable.getSearchActivity();
 
        // create the necessary intent to set up a search-and-forward operation 
        // in the voice search system.   We have to keep the bundle separate, 
        // because it becomes immutable once it enters the PendingIntent 
        Intent queryIntent = new Intent(Intent.ACTION_SEARCH);
        queryIntent.setComponent(searchActivity);
        PendingIntent pending = PendingIntent.getActivity(
                getContext(), 0, queryIntent, PendingIntent.FLAG_ONE_SHOT);
 
        // Now set up the bundle that will be inserted into the pending intent 
        // when it's time to do the search.  We always build it here (even if empty) 
        // because the voice search activity will always need to insert "QUERY" into 
        // it anyway. 
        Bundle queryExtras = new Bundle();

7
CodeRank
This code example shows how to use the following methods:getSuggestAuthority, getSuggestPath, getSuggestSelection, sleep
    public Cursor getSuggestions(SearchableInfo searchable, String query, int limit) {
        if (searchable == null) {
            return null; 
        } 
 
        String authority = searchable.getSuggestAuthority();
        if (authority == null) {
            return null; 
        } 
 
        Uri.Builder uriBuilder = new Uri.Builder()
                .scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority)
                .query("")  // TODO: Remove, workaround for a bug in Uri.writeToParcel()
                .fragment("");  // TODO: Remove, workaround for a bug in Uri.writeToParcel()
 
        // if content path provided, insert it now 
        final String contentPath = searchable.getSuggestPath();
        if (contentPath != null) {
            uriBuilder.appendEncodedPath(contentPath);

6
CodeRank
This code example shows how to use the following methods:getSuggestAuthority, getSuggestPath, getSuggestSelection
            String query, int limit) {
        if (searchable == null) {
            return null; 
        } 
 
        String authority = searchable.getSuggestAuthority();
        if (authority == null) {
            return null; 
        } 
 
        Uri.Builder uriBuilder = new Uri.Builder()
                .scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority)
                .query("")  // TODO: Remove, workaround for a bug in Uri.writeToParcel()
                .fragment("");  // TODO: Remove, workaround for a bug in Uri.writeToParcel()
 
        // if content path provided, insert it now 
        final String contentPath = searchable.getSuggestPath();
        if (contentPath != null) {
            uriBuilder.appendEncodedPath(contentPath);

6
CodeRank
This code example shows how to use the following methods:getSuggestAuthority, getSuggestPath, getSuggestSelection
    public Cursor getSuggestions(SearchableInfo searchable, String query, int limit) {
        if (searchable == null) {
            return null; 
        } 
 
        String authority = searchable.getSuggestAuthority();
        if (authority == null) {
            return null; 
        } 
 
        Uri.Builder uriBuilder = new Uri.Builder()
                .scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority)
                .query("")  // TODO: Remove, workaround for a bug in Uri.writeToParcel()
                .fragment("");  // TODO: Remove, workaround for a bug in Uri.writeToParcel()
 
        // if content path provided, insert it now 
        final String contentPath = searchable.getSuggestPath();
        if (contentPath != null) {
            uriBuilder.appendEncodedPath(contentPath);

6
CodeRank
This code example shows how to use the following methods:getSuggestAuthority
                (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
        return searchManager.getSuggestions(mSearchable, query);
    } 
 
    public boolean supportsSuggestions() { 
        return !TextUtils.isEmpty(mSearchable.getSuggestAuthority());
    } 
 
    public void close() { 
    } 
 
    public boolean supportsVoiceSearch() { 
        return getName().equals(SearchEngine.GOOGLE);
    } 
 
    @Override 
    public String toString() {
        return "ActivitySearchEngine{" + mSearchable + "}";
    } 
 
6
CodeRank
This code example shows how to use the following methods:getSuggestAuthority, getSuggestPath, getSuggestSelection
	public Cursor getSuggestions(String query) {
		if (mSearchableInfo == null) {
			return null; 
		} 
 
		String authority = mSearchableInfo.getSuggestAuthority();
		if (authority == null) {
			return null; 
		} 
 
		Uri.Builder uriBuilder = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(authority)
				.query("") // TODO: Remove, workaround for a bug in
							// Uri.writeToParcel() 
				.fragment(""); // TODO: Remove, workaround for a bug in
								// Uri.writeToParcel() 
 
		// if content path provided, insert it now 
		final String contentPath = mSearchableInfo.getSuggestPath();
		if (contentPath != null) {
			uriBuilder.appendEncodedPath(contentPath);

5
CodeRank
This code example shows how to use the following methods:getSuggestAuthority
            } 
            return false; 
        } 
 
        protected boolean isSearchableContacts(SearchableInfo searchable) {
            return TextUtils.equals(ContactsContract.AUTHORITY, searchable.getSuggestAuthority());
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getSuggestAuthority
                (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
        return searchManager.getSuggestions(mSearchable, query);
    } 
 
    public boolean supportsSuggestions() { 
        return !TextUtils.isEmpty(mSearchable.getSuggestAuthority());
    } 
 
    public void close() { 
    } 
 
    public boolean supportsVoiceSearch() { 
        return getName().equals(SearchEngine.GOOGLE);
    } 
 
    @Override 
    public String toString() {
        return "ActivitySearchEngine{" + mSearchable + "}";
    } 
 
4
CodeRank
This code example shows how to use the following methods:getSuggestAuthority
 
        public LiveSourceCheck(String src, ComponentName componentName, String query) {
            mSrc = src;
            mSearchable = mSearchManager.getSearchableInfo(componentName);
            assert(mSearchable != null);
            assert(mSearchable.getSuggestAuthority() != null);
            mQuery = query;
        } 
 
        public void run() { 
            Cursor cursor = null;
            try { 
                final long start = System.nanoTime();
                cursor = getSuggestions(mSearchable, mQuery);
                long end = System.nanoTime();
                long elapsed = (end - start);
                if (cursor == null) {
                    Log.d(TAG, mSrc + ": null cursor in " + formatTime(elapsed)
                            + " for '" + mQuery + "'");
                } else { 
3
CodeRank
This code example shows how to use the following methods:getSuggestAuthority
                (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
        return searchManager.getSuggestions(mSearchable, query);
    } 
 
    public boolean supportsSuggestions() { 
        return !TextUtils.isEmpty(mSearchable.getSuggestAuthority());
    } 
 
    public void close() { 
    } 
 
    public boolean supportsVoiceSearch() { 
        return getName().equals(SearchEngine.GOOGLE);
    } 
 
    @Override 
    public String toString() {
        return "ActivitySearchEngine{" + mSearchable + "}";
    } 
 
4
CodeRank

Related Android SearchableInfo Questions & Answers:

See Code Examples for Android SearchableInfo Methods: