Example usage for android.app SearchManager QUERY

List of usage examples for android.app SearchManager QUERY

Introduction

In this page you can find the example usage for android.app SearchManager QUERY.

Prototype

String QUERY

To view the source code for android.app SearchManager QUERY.

Click Source Link

Document

Intent extra data key: Use this key with android.content.Intent#getStringExtra content.Intent.getStringExtra() to obtain the query string from Intent.ACTION_SEARCH.

Usage

From source file:org.andstatus.app.TimelineActivity.java

private void parseAppSearchData(Intent intentNew) {
    Bundle appSearchData = intentNew.getBundleExtra(SearchManager.APP_DATA);
    if (appSearchData != null) {
        // We use other packaging of the same parameters in onSearchRequested
        mListParametersNew.setTimelineType(
                TimelineTypeEnum.load(appSearchData.getString(IntentExtra.EXTRA_TIMELINE_TYPE.key)));
        if (mListParametersNew.getTimelineType() != TimelineTypeEnum.UNKNOWN) {
            mListParametersNew.setTimelineCombined(appSearchData.getBoolean(
                    IntentExtra.EXTRA_TIMELINE_IS_COMBINED.key, mListParametersNew.isTimelineCombined()));
            /* The query itself is still from the Intent */
            mListParametersNew.mSearchQuery = TimelineListParameters
                    .notNullString(intentNew.getStringExtra(SearchManager.QUERY));
            mListParametersNew.mSelectedUserId = appSearchData.getLong(IntentExtra.EXTRA_SELECTEDUSERID.key,
                    mListParametersNew.mSelectedUserId);
            if (!TextUtils.isEmpty(mListParametersNew.mSearchQuery)
                    && appSearchData.getBoolean(IntentExtra.EXTRA_GLOBAL_SEARCH.key, false)) {
                setSyncing("Global search: " + mListParametersNew.mSearchQuery, true);
                MyServiceManager//from  w w  w  . j  a va 2s .  c  o  m
                        .sendForegroundCommand(
                                CommandData.searchCommand(
                                        isTimelineCombined() ? ""
                                                : MyContextHolder.get().persistentAccounts()
                                                        .getCurrentAccountName(),
                                        mListParametersNew.mSearchQuery));
            }
        }
    }
}

From source file:com.supremainc.biostar2.main.HomeActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);/*from w ww .  jav a2s  .  c  o  m*/
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        if (BuildConfig.DEBUG) {
            Log.e("search", "query:" + query);
        }
        if (query != null && query.length() > 0) {
            if (mSuggestions == null) {
                mSuggestions = new SearchRecentSuggestions(this, SearchSuggestionProvider.AUTHORITY,
                        SearchSuggestionProvider.MODE);
            }
            mSuggestions.saveRecentQuery(query, null);
        }
        mFragment.onSearch(query);
        return;
    }

    if (BuildConfig.DEBUG) {
        Log.i(TAG, "onNewIntent:");
    }

    if (intent != null) {
        String action = intent.getAction();
        if (action != null && action.startsWith(Setting.ACTION_NOTIFICATION_START)
                && mPermissionDataProvider != null
                && mPermissionDataProvider.getPermission(PERMISSION_MODULE.DOOR, true)) {
            gotoScreen(ScreenType.ALARM_LIST, null, true);
        }
    }
}

From source file:cz.muni.fi.japanesedictionary.main.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    if (intent == null) {
        return;/*ww  w . j a  v a 2  s . c  o m*/
    }
    Log.i(LOG_TAG, "Voice search intent recognized");
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {

        String query = intent.getStringExtra(SearchManager.QUERY);
        Log.i(LOG_TAG, "Voice search intent recognized" + query);
        MenuItem searchItem = mMenu.findItem(R.id.action_search);

        MenuItemCompat.expandActionView(searchItem);
        mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
        mSearchView.setQuery(query, true);
        ResultFragmentList fragmentList = (ResultFragmentList) getSupportFragmentManager()
                .findFragmentByTag(getFragmentTag(mPager.getCurrentItem()));
        mCurFilter = query;
        fragmentList.search(mCurFilter);

    }

    Bundle bundle = intent.getExtras();
    if (bundle != null) {
        Log.i(LOG_TAG, "Bundle: " + bundle);
        if (bundle.containsKey("search")) {
            mSearchVisible = bundle.getBoolean("search", false);
            if (!mSearchVisible) {

                ResultFragmentList fragmentList = (ResultFragmentList) getSupportFragmentManager()
                        .findFragmentByTag(getFragmentTag(mPager.getCurrentItem()));
                if (fragmentList != null) {
                    fragmentList.search(null);
                }
            }
        }
    }
    super.onNewIntent(intent);
}

From source file:ee.ioc.phon.android.speak.RecognizerIntentActivity.java

/**
 * <p>Returns the transcription results (matches) to the caller,
 * or sends them to the pending intent, or performs a web search.</p>
 *
 * <p>If a pending intent was specified then use it. This is the case with
 * applications that use the standard search bar (e.g. Google Maps and YouTube).</p>
 *
 * <p>Otherwise. If there was no caller (i.e. we cannot return the results), or
 * the caller asked us explicitly to perform "web search", then do that, possibly
 * disambiguating the results or redoing the recognition.
 * This is the case when K6nele was launched from its launcher icon (i.e. no caller),
 * or from a browser app./*from  w ww  .ja v  a 2 s  . com*/
 * (Note that trying to return the results to Google Chrome does not seem to work.)</p>
 *
 * <p>Otherwise. Just return the results to the caller.</p>
 *
 * <p>Note that we assume that the given list of matches contains at least one
 * element.</p>
 *
 * @param handler message handler
 * @param matches transcription results (one or more hypotheses)
 */
private void returnOrForwardMatches(final Handler handler, ArrayList<String> matches) {
    // Throw away matches that the user is not interested in
    int maxResults = mExtras.getInt(RecognizerIntent.EXTRA_MAX_RESULTS);
    if (maxResults > 0 && matches.size() > maxResults) {
        matches.subList(maxResults, matches.size()).clear();
    }

    if (mExtraResultsPendingIntent == null) {
        if (getCallingActivity() == null || RecognizerIntent.ACTION_WEB_SEARCH.equals(getIntent().getAction())
                || mExtras.getBoolean(RecognizerIntent.EXTRA_WEB_SEARCH_ONLY)) {
            handleResultsByWebSearch(this, handler, matches);
            return;
        } else {
            setResultIntent(handler, matches);
        }
    } else {
        Bundle bundle = mExtras.getBundle(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE);
        if (bundle == null) {
            bundle = new Bundle();
        }
        String match = matches.get(0);
        //mExtraResultsPendingIntentBundle.putString(SearchManager.QUERY, match);
        Intent intent = new Intent();
        intent.putExtras(bundle);
        // This is for Google Maps, YouTube, ...
        intent.putExtra(SearchManager.QUERY, match);
        // This is for SwiftKey X, ...
        intent.putStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS, matches);
        String message = "";
        if (matches.size() == 1) {
            message = match;
        } else {
            message = matches.toString();
        }
        // Display a toast with the transcription.
        handler.sendMessage(
                createMessage(MSG_TOAST, String.format(getString(R.string.toastForwardedMatches), message)));
        try {
            mExtraResultsPendingIntent.send(this, Activity.RESULT_OK, intent);
        } catch (CanceledException e) {
            handler.sendMessage(createMessage(MSG_TOAST, e.getMessage()));
        }
    }
    finish();
}

From source file:nl.mpcjanssen.simpletask.Simpletask.java

@Override
protected void onNewIntent(@NotNull Intent intent) {
    super.onNewIntent(intent);
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        Intent currentIntent = getIntent();
        currentIntent.putExtra(SearchManager.QUERY, intent.getStringExtra(SearchManager.QUERY));
        setIntent(currentIntent);//  w w  w  .ja v a  2s.  c om
        options_menu.findItem(R.id.search).collapseActionView();
    } else if (CalendarContract.ACTION_HANDLE_CUSTOM_EVENT.equals(intent.getAction())) {
        Uri uri = Uri.parse(intent.getStringExtra(CalendarContract.EXTRA_CUSTOM_APP_URI));
        String search = uri.getLastPathSegment();
        // TODO: activate search
    } else if (intent.getExtras() != null) {
        // Only change intent if it actually contains a filter
        setIntent(intent);
    }
    Log.v(TAG, "onNewIntent: " + intent);

}

From source file:org.voidsink.anewjkuapp.utils.AppUtils.java

public static void showEventLocation(Context context, String location) {
    Intent intent = new Intent(context, MainActivity.class)
            .putExtra(MainActivity.ARG_SHOW_FRAGMENT_ID, R.id.nav_map)
            .putExtra(MainActivity.ARG_SAVE_LAST_FRAGMENT, false).setAction(Intent.ACTION_SEARCH)
            .addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    if (!TextUtils.isEmpty(location)) {
        intent.putExtra(SearchManager.QUERY, location);
        intent.putExtra(MainActivity.ARG_EXACT_LOCATION, true);
    } else {/*from www . j a v a 2 s  . com*/
        intent.putExtra(SearchManager.QUERY, "Uniteich");
    }
    context.startActivity(intent);
}

From source file:com.android.music.TrackBrowserFragment.java

void doSearch() {
    CharSequence title = null;/* w  ww. j av a 2  s  .c  o m*/
    String query = null;

    Intent i = new Intent();
    i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    title = mCurrentTrackName;
    if (MediaStore.UNKNOWN_STRING.equals(mCurrentArtistNameForAlbum)) {
        query = mCurrentTrackName;
    } else {
        query = mCurrentArtistNameForAlbum + " " + mCurrentTrackName;
        i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistNameForAlbum);
    }
    if (MediaStore.UNKNOWN_STRING.equals(mCurrentAlbumName)) {
        i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, mCurrentAlbumName);
    }
    i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "audio/*");
    title = getString(R.string.mediasearch, title);
    i.putExtra(SearchManager.QUERY, query);

    startActivity(Intent.createChooser(i, title));

}

From source file:ee.ioc.phon.android.speak.RecognizerIntentActivity.java

private void handleResultsByWebSearch(final Context context, final Handler handler,
        final ArrayList<String> results) {
    // Some tweaking to cleanup the UI that would show under the
    // dialog window that we are about to open.
    runOnUiThread(new Runnable() {
        public void run() {
            mLlTranscribing.setVisibility(View.GONE);
        }//  w  w  w .  j  a v a  2s .  c om
    });

    Intent searchIntent;
    if (results.size() == 1) {
        searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
        searchIntent.putExtra(SearchManager.QUERY, results.get(0));
    } else {
        // TODO: it would be a bit cleaner to pass ACTION_WEB_SEARCH
        // via a pending intent
        searchIntent = new Intent(this, DetailsActivity.class);
        searchIntent.putExtra(DetailsActivity.EXTRA_TITLE, getString(R.string.dialogTitleHypotheses));
        searchIntent.putExtra(DetailsActivity.EXTRA_STRING_ARRAY, results.toArray(new String[results.size()]));
    }
    startActivity(searchIntent);
}

From source file:org.huxizhijian.hhcomicviewer.ui.entry.ComicDetailsActivity.java

private void searchAuthor() {
    Intent intent;/*w ww.j a  v a  2s . c  o m*/
    if (mComic == null)
        return;
    intent = new Intent(this, SearchActivity.class);
    intent.setAction(Intent.ACTION_SEARCH);
    intent.putExtra(SearchManager.QUERY, mComic.getAuthor());
    startActivity(intent);
}