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:br.com.mybaby.contatos.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Util.enableStrictMode();/* w  w  w.  j  a  v a 2 s.  co  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.contatos_main);

    // Check if two pane bool is set based on resource directories
    isTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes);

    // 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);
    }

    if (isTwoPaneLayout) {
        // If two pane layout, locate the contact detail fragment
        mContactDetailFragment = (ContactDetailFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contact_detail);
    }
}

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

/** Called when the activity is first created. */
@Override/*from  w w w .  j a  v  a 2s.c om*/
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 {
        // Creates the backing adapter for the ListView.
        adapter = new SimpleCursorAdapter(this, R.layout.attibute_row, null, dataColumns, viewIDs,
                SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

        adapter.setViewBinder(new ItemAttributeListViewBinder());

        ListView itemListView = (ListView) findViewById(R.id.market_group_list);
        //itemListView.setOnItemClickListener(new MarketGroupOnItemListClickListener());
        // 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.ces.cloudnote.app.contactslist.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();/*from  w  ww.  ja v a 2s  . 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.contact);

    // Check if two pane bool is set based on resource directories
    isTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes);

    // 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);
    }

    if (isTwoPaneLayout) {
        // If two pane layout, locate the contact detail fragment
        mContactDetailFragment = (ContactDetailFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contact_detail);
    }
}

From source file:android.com.example.contactslist.ui.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();//ww w  . j  av  a 2 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 two pane bool is set based on resource directories
    isTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes);

    // 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);
    }

    if (isTwoPaneLayout) {
        // If two pane layout, locate the contact detail fragment
        mContactDetailFragment = (ContactDetailFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contact_detail);
    }
}

From source file:com.rowland.hashtrace.ui.activities.SearchActivity.java

/**
 * Getting intent search query/*from   www.ja  v a  2s  .  c o m*/
 */
private String getIntentSearchQuery(Intent intent) {
    String query = "Tweet";

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        query = intent.getStringExtra(SearchManager.QUERY);
    }

    return query;
}

From source file:com.rowland.movies.ui.fragments.SearchFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Restore any previous states
    if (savedInstanceState != null) {
        // Restore query string
        mQuery = savedInstanceState.getString(SearchManager.QUERY, mQuery);
    }/*from   w ww  . jav  a  2 s  .c  om*/
    // Initialize the list
    mMovieList = new ArrayList<>();
    // Initialize the sort order
    mSortOrder = ESortOrder.POPULAR_DESCENDING;
    // Check if we a value the query string
    if (mQuery != null) {
        // Create a Bundle object
        Bundle data = new Bundle();
        // Assign the query string as argument
        data.putString(SearchManager.QUERY, mQuery);
        // Initialize the Loader
        getLoaderManager().initLoader(0, data, this);
    }
}

From source file:com.andrada.sitracker.ui.SearchActivity.java

@AfterViews
void afterViews() {
    String query = getIntent().getStringExtra(SearchManager.QUERY);
    if (query == null && mQuery != null) {
        query = mQuery;/*w w w  . ja  va  2s  . c o m*/
    }
    mQuery = query;

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

From source file:net.abcdroid.devfest12.ui.SearchActivity.java

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);/*  w  ww .j  av  a  2  s . co m*/
    String query = intent.getStringExtra(SearchManager.QUERY);

    setTitle(Html.fromHtml(getString(R.string.title_search_query, query)));

    mSessionsFragment.reloadFromArguments(
            intentToFragmentArguments(new Intent(Intent.ACTION_VIEW, Sessions.buildSearchUri(query))));

    EasyTracker.getTracker().trackView("Search: " + query);
    LOGD("Tracker", "Search: " + query);

    updateDetailBackground();
}

From source file:org.openmrs.client.activities.FindActiveVisitsSearchActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        mQuery = intent.getStringExtra(SearchManager.QUERY);
        mEmptyList.setVisibility(View.GONE);
        mVisitsListView.setEmptyView(mSpinner);
        mAdapter = new ActiveVisitsArrayAdapter(this, R.layout.find_visits_row,
                new VisitDAO().findActiveVisitsByPatientNameLike(mQuery));
        mVisitsListView.setAdapter(mAdapter);
        stopLoader();/*w w  w  .j a v a 2 s  .  co  m*/
        if (mFindActiveVisitItem != null) {
            MenuItemCompat.collapseActionView(mFindActiveVisitItem);
        }
    }
}

From source file:com.ute.bihapi.wydarzeniatekstowe.thirdScreenActivities.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    /*if (BuildConfig.DEBUG) {
    Utils.enableStrictMode();//from  w w  w .  j  a  v  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_contacts_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);
    }

    memory = new Bundle();
    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras != null) {

            for (String layoutElement : layoutElements) {
                if (extras.get(layoutElement) != null) {
                    if (layoutElement.equals("Person")) {
                        Bundle mp = null;
                        mp = extras.getBundle("Person");
                        Log.i("Memory",
                                "Got entry from previous activity: " + mp.keySet().toArray()[0].toString() + " "
                                        + mp.get(mp.keySet().toArray()[0].toString()).toString());
                        memory.putBundle("Person", mp);
                    } else if (layoutElement.equals("Point")) {
                        Bundle mp = null;
                        mp = extras.getBundle("Point");
                        Log.i("Memory",
                                "Got entry from previous activity: " + mp.keySet().toArray()[0].toString() + " "
                                        + mp.get(mp.keySet().toArray()[0].toString()).toString());
                        memory.putBundle("Point", mp);
                    } else {
                        memory.putString(layoutElement, extras.get(layoutElement).toString());
                        Log.i("Memory", "Got entry from prevoius activity: " + layoutElement + ": "
                                + extras.get(layoutElement).toString());
                    }
                }
            }
        }
    }
}