Example usage for android.content Intent ACTION_SEARCH

List of usage examples for android.content Intent ACTION_SEARCH

Introduction

In this page you can find the example usage for android.content Intent ACTION_SEARCH.

Prototype

String ACTION_SEARCH

To view the source code for android.content Intent ACTION_SEARCH.

Click Source Link

Document

Activity Action: Perform a search.

Usage

From source file:com.nma.util.sdcardtrac.SearchableActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        query = intent.getStringExtra(SearchManager.QUERY);
        // Replace spaces with wildcard
        //query = query.replace(' ', '%');
        if (SettingsActivity.ENABLE_DEBUG)
            Log.d(getClass().getName(), "Starting search: " + query);
        // Load data
        getSupportLoaderManager().restartLoader(0, null, this);
    }//from  w w w  . jav a 2  s. c  o m
}

From source file:org.openmrs.mobile.activities.FindPatientsSearchActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        mSearching = true;/* w  w  w . jav a2 s .  com*/
        mLastSearchId++;
        mEmptyList.setVisibility(View.GONE);
        mPatientsListView.setEmptyView(mSpinner);
        mSearchedPatientsList = new ArrayList<Patient>();
        mAdapter = new PatientArrayAdapter(this, R.layout.find_patients_row, mSearchedPatientsList);
        mPatientsListView.setAdapter(mAdapter);
        mLastQuery = intent.getStringExtra(SearchManager.QUERY);
        new FindPatientsManager()
                .findPatient(FindPatientsHelper.createFindPatientListener(mLastQuery, mLastSearchId, this));

        if (mFindPatientMenuItem != null) {
            MenuItemCompat.collapseActionView(mFindPatientMenuItem);
        }
    }
}

From source file:com.app_software.chromisstock.ProductListActivity.java

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

    setContentView(R.layout.activity_product_list);

    // Restore state
    if (savedInstanceState != null) {
        m_ListFragment = (ProductListFragment) getSupportFragmentManager().getFragment(savedInstanceState,
                "m_ListFragment");
    } else {/*  w w w  . j  ava  2s.  co  m*/

        // If our layout has a container for the image selector fragment,
        // create and add it
        ViewGroup layout = (ViewGroup) findViewById(R.id.product_list);
        if (layout != null) {
            Bundle args = new Bundle();

            Intent i = getIntent();
            if (i != null) {
                if (Intent.ACTION_SEARCH.equals(i.getAction())) {
                    String search = i.getStringExtra(SearchManager.QUERY);
                    args.putString(ProductListFragment.ARG_SEARCH, search);
                }
            }

            // Add image selector fragment to the activity's container layout
            m_ListFragment = new ProductListFragment();
            m_ListFragment.setArguments(args);

            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            fragmentTransaction.replace(layout.getId(), m_ListFragment, ProductListFragment.class.getName());

            // Commit the transaction
            fragmentTransaction.commit();
        }
    }

    if (findViewById(R.id.product_detail_container) != null) {
        // The detail container view will be present only in the
        // large-screen layouts (res/values-large and
        // res/values-sw600dp). If this view is present, then the
        // activity should be in two-pane mode.
        mTwoPane = true;

        // In two-pane mode, list items should be given the
        // 'activated' state when touched.
        m_ListFragment.setActivateOnItemClick(true);
    }

}

From source file:com.jbirdvegas.mgerrit.ProjectsList.java

private void handleIntent(Intent intent) {
    // Searching is already handled when the query text changes.
    if (!Intent.ACTION_SEARCH.equals(intent.getAction()))
        loadAdapter();//w  w w.  j a v a2  s.  c  o m
}

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

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        mQuery = intent.getStringExtra(SearchManager.QUERY);
        Intent searchIntent = new Intent(this, FindPatientsSearchActivity.class);
        searchIntent.putExtra(SearchManager.QUERY, mQuery);
        startActivityForResult(searchIntent, 1);
        intent.setAction(null);//from www.  j av a2s.co m
        if (mFindPatientMenuItem != null) {
            MenuItemCompat.collapseActionView(mFindPatientMenuItem);
        }
    }
}

From source file:com.teocci.utubinbg.MainActivity.java

/**
 * Handle search intent and queries YouTube for videos
 *
 * @param intent/*from   ww w  . ja  va  2  s.  c  o m*/
 */
private void handleIntent(Intent intent) {

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

        viewPager.setCurrentItem(2, true); //switch to search fragment

        if (searchFragment != null) {
            searchFragment.searchQuery(query);
        }
    }
}

From source file:org.klnusbaum.udj.ArtistsDisplayFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    Log.d(TAG, "In on list item clicked");
    final String artist = (String) artistsAdapter.getItem(position);
    Intent artistIntent = new Intent(Intent.ACTION_SEARCH);
    artistIntent.setClass(getActivity(), ArtistSearchActivity.class);
    artistIntent.putExtra(SearchManager.QUERY, artist);
    startActivityForResult(artistIntent, 0);
}

From source file:com.battlelancer.seriesguide.ui.SearchActivity.java

private void handleIntent(Intent intent) {
    if (intent == null) {
        return;//w ww .  j  a  va 2s  .co m
    }
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        Bundle extras = getIntent().getExtras();

        // searching episodes within a show?
        Bundle appData = extras.getBundle(SearchManager.APP_DATA);
        if (appData != null) {
            String showTitle = appData.getString(EpisodeSearchFragment.InitBundle.SHOW_TITLE);
            if (!TextUtils.isEmpty(showTitle)) {
                // change title + switch to episodes tab if show restriction was submitted
                viewPager.setCurrentItem(EPISODES_TAB_INDEX);
            }
        }

        // setting the query automatically triggers a search
        String query = extras.getString(SearchManager.QUERY);
        searchBar.setText(query);
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri data = intent.getData();
        String id = data.getLastPathSegment();
        displayEpisode(id);
        Utils.trackCustomEvent(this, TAG, "Search action", "View");
        finish();
    }
}

From source file:com.bukanir.android.activities.SearchActivity.java

private void handleSearchIntent(Intent intent) {
    Log.d(TAG, "handleSearchIntent");
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        if (Utils.isNetworkAvailable(this)) {
            searchTask = new SearchTask();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                searchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, query);
            } else {
                searchTask.execute(query);
            }/*from  w w  w .  j  a  v a 2  s  .co  m*/
        } else {
            Toast.makeText(this, getString(R.string.network_not_available), Toast.LENGTH_LONG).show();
        }
    }
}

From source file:com.nbonnec.mediaseb.ui.activity.SearchActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        search = intent.getStringExtra(SearchManager.QUERY);
    }
}