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:it.gulch.linuxday.android.activities.SearchResultActivity.java

private void handleIntent(Intent intent, boolean isNewIntent) {
    String intentAction = intent.getAction();
    if (Intent.ACTION_SEARCH.equals(intentAction) || GMS_ACTION_SEARCH.equals(intentAction)) {
        // Normal search, results are displayed here
        String query = intent.getStringExtra(SearchManager.QUERY);
        if (query != null) {
            query = query.trim();//from   ww  w.ja v a 2  s .  c  om
        }
        if ((query == null) || (query.length() < MIN_SEARCH_LENGTH)) {
            MessageDialogFragment.newInstance(R.string.error_title, R.string.search_length_error)
                    .show(getSupportFragmentManager());
            return;
        }

        currentQuery = query;
        if (searchView != null) {
            setSearchViewQuery(query);
        }

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
            // Legacy search mode for Eclair
            getSupportActionBar().setSubtitle(query);
        }

        SearchResultListFragment f = SearchResultListFragment.newInstance(query);
        getSupportFragmentManager().beginTransaction().replace(R.id.content, f).commit();

    } else if (Intent.ACTION_VIEW.equals(intentAction)) {
        // Search suggestion, dispatch to EventDetailsActivity
        Intent dispatchIntent = new Intent(this, EventDetailsActivity.class).setData(intent.getData());
        startActivity(dispatchIntent);

        if (!isNewIntent) {
            finish();
        }
    }
}

From source file:com.joulespersecond.seattlebusbot.SearchActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        // handles a click on a search suggestion; launches activity to show word
        /*/*  w  w  w.j a  va2s. c om*/
        Intent wordIntent = new Intent(this, WordActivity.class);
        wordIntent.setData(intent.getData());
        startActivity(wordIntent);
        finish();
        */
    } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        //Analytics
        ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
                getString(R.string.analytics_action_button_press),
                getString(R.string.analytics_label_button_press_search_button));

        // handles a search query
        String query = intent.getStringExtra(SearchManager.QUERY);
        doSearch(query);
    }
}

From source file:fr.eoidb.activity.MarketGroupItemListActivity.java

/** Called when the activity is first created. */
@Override// ww  w  .j a va  2 s. c  o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.market_group_list);

    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // handles a search query
        query = intent.getStringExtra(SearchManager.QUERY);
        showResults();
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        // handles a click on a search suggestion; launches activity to show word
        Intent itemIntent = new Intent(this, ItemInfoActivity.class);
        itemIntent.setData(intent.getData());
        startActivity(itemIntent);
        finish();
    } else {
        // If there is no data associated with the Intent, sets the data to the default URI, which
        // accesses a list of notes.
        if (intent.getData() == null) {
            intent.setData(MarketGroups.CONTENT_URI);
        }

        if (getIntent().getData().equals(MarketGroups.CONTENT_URI)) {
            marketGroupId = -1;
        } else {
            marketGroupId = ContentUris.parseId(getIntent().getData());
        }

        // Creates the backing adapter for the ListView.
        adapter = new SimpleCursorAdapter(this, R.layout.market_group_row, null, dataColumns, viewIDs,
                SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

        adapter.setViewBinder(new MarketGroupListViewBinder(true));

        ListView itemListView = (ListView) findViewById(R.id.market_group_list);
        itemListView.setOnItemClickListener(new ItemOnItemListClickListener());
        // Sets the ListView's adapter to be the cursor adapter that was just created.
        itemListView.setAdapter(adapter);

        getSupportLoaderManager().initLoader(LOADER_ID, null, this);
    }
}

From source file:com.saarang.samples.apps.iosched.ui.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.saarang.samples.apps.iosched.R.layout.activity_search);

    Toolbar toolbar = getActionBarToolbar();
    toolbar.setTitle(com.saarang.samples.apps.iosched.R.string.title_search);
    toolbar.setNavigationIcon(com.saarang.samples.apps.iosched.R.drawable.ic_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override/*from  ww w.  ja va2 s .  c  o  m*/
        public void onClick(View view) {
            navigateUpToFromChild(SearchActivity.this, IntentCompat
                    .makeMainActivity(new ComponentName(SearchActivity.this, BrowseSessionsActivity.class)));
        }
    });

    FragmentManager fm = getFragmentManager();
    mSessionsFragment = (SessionsFragment) fm
            .findFragmentById(com.saarang.samples.apps.iosched.R.id.fragment_container);

    String query = getIntent().getStringExtra(SearchManager.QUERY);
    query = query == null ? "" : query;
    mQuery = query;

    if (mSessionsFragment == null) {
        mSessionsFragment = new SessionsFragment();
        Bundle args = intentToFragmentArguments(new Intent("com.saarang.samples.apps.iosched.SESSION_VIEW",
                ScheduleContract.Sessions.buildSearchUri(query)));
        mSessionsFragment.setArguments(args);
        fm.beginTransaction().add(com.saarang.samples.apps.iosched.R.id.fragment_container, mSessionsFragment)
                .commit();
    }

    if (mSearchView != null) {
        mSearchView.setQuery(query, false);
    }

    overridePendingTransition(0, 0);
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();//from  ww w .ja va  2  s .c  om
    mQuery = intent.getStringExtra(SearchManager.QUERY);

    setContentView(R.layout.activity_search);

    if (!UIUtils.isHoneycombTablet(this)) {
        final CharSequence title = getString(R.string.title_search_query, mQuery);
        setTitle(title);
    }

    mTabs = (ScrollableTabs) findViewById(R.id.viewpagerheader_search);
    mViewPager = (ViewPager) findViewById(R.id.viewpager_search);
    mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.viewpager_page_margin));
    mViewPager.setPageMarginDrawable(R.drawable.viewpager_margin);
    mAdapter = new SearchPagerAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(mAdapter);
    mTabs.setAdapter(mAdapter);
    mViewPager.setOnPageChangeListener(mTabs);
}

From source file:com.gm.goldencity.activity.search.SearchActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);/*  ww w.  j  av a 2  s .  c  o m*/

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        if (intent.hasExtra(SearchManager.QUERY)) {
            String query = intent.getStringExtra(SearchManager.QUERY);
            SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                    SuggestionProvider.AUTHORITY, SuggestionProvider.MODE);
            suggestions.saveRecentQuery(query, null);
            if (!TextUtils.isEmpty(query)) {
                searchview.setQuery(query, false);
            }
        }
    }

    initSearchFragment();
}

From source file:tw.idv.gasolin.pycontw2012.ui.SearchActivity.java

@Override
public void onNewIntent(Intent intent) {
    mQuery = intent.getStringExtra(SearchManager.QUERY);

    final CharSequence title = getString(R.string.title_search_query, mQuery);
    getActivityHelper().setActionBarTitle(title);

    mTabHost.setCurrentTab(0);/*w  w  w.  j  a  v  a2s  .  c  o m*/

    mSessionsFragment.reloadFromArguments(getSessionsFragmentArguments());
}

From source file:net.ddns.mlsoftlaberge.contactslist.ui.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();//from   w  w w .jav a2 s  . c  o m
    }
    super.onCreate(savedInstanceState);

    // Set main content view. On smaller screen devices this is a single pane view with one
    // fragment. One larger screen devices this is a two pane view with two fragments.
    setContentView(R.layout.activity_main);

    // Check if this activity instance has been triggered as a result of a search query. This
    // will only happen on pre-HC OS versions as from HC onward search is carried out using
    // an ActionBar SearchView which carries out the search in-line without loading a new
    // Activity.
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {

        // Fetch query from intent and notify the fragment that it should display search
        // results instead of all contacts.
        String searchQuery = getIntent().getStringExtra(SearchManager.QUERY);
        ContactsListFragment mContactsListFragment = (ContactsListFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contact_list);

        // This flag notes that the Activity is doing a search, and so the result will be
        // search results rather than all contacts. This prevents the Activity and Fragment
        // from trying to a search on search results.
        isSearchResultView = true;
        mContactsListFragment.setSearchQuery(searchQuery);

        // Set special title for search results
        String title = getString(R.string.contacts_list_search_results_title, searchQuery);
        setTitle(title);
    }

}

From source file:org.androidtitlan.estoesgoogle.ui.SearchActivity.java

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);// w  w w.  ja v  a  2  s  .co  m
    mQuery = intent.getStringExtra(SearchManager.QUERY);

    final CharSequence title = getString(R.string.title_search_query, mQuery);
    getActivityHelper().setActionBarTitle(title);

    mTabHost.setCurrentTab(0);

    mSessionsFragment.reloadFromArguments(getSessionsFragmentArguments());
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.SignSearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate() " + this.hashCode());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_activity);
    if (null != savedInstanceState) {
        this.query = savedInstanceState.getString(QUERY);
    } else {/*from  ww w .  ja  va2s. c  om*/
        final Intent intent = getIntent();
        this.query = StringUtils
                .trimToEmpty(StringUtils.stripToEmpty(intent.getStringExtra(SearchManager.QUERY)));
        Validate.notNull(this.query, "The query supplied to this activity is null!");
    }
    setupRecyclerView();
    setupSupportActionBar();
    this.signSearchTask = new SearchSignsTask(this);
    this.signSearchTask.execute(this.query);
}