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:sk.mpage.androidsample.searchviewtoolbar.SearchActivity.java

private void handleIntent(Intent intent) {
    Log.i("SEARCHVIEWMAIN", "handleIntent");
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        query = intent.getStringExtra(SearchManager.QUERY);
        Log.d("searchtoolbar", "Query: " + query);
        getSupportActionBar().setTitle("Search for : \"" + query + "\"");

        FragmentManager fragmentManager = getSupportFragmentManager();
        Bundle args = new Bundle();
        args.putString("query", query);
        Fragment fragment = new SearchFragment();
        fragment.setArguments(args);// w  w  w.  j  a v  a  2s .  c o  m
        fragmentManager.beginTransaction().replace(R.id.main_fragment_container, fragment).commit();

    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        result_id = Integer.valueOf(intent.getData().getLastPathSegment());
        String[] names = getResources().getStringArray(R.array.names);
        query = names[result_id];
        getSupportActionBar().setTitle(query);
        Log.d("searchtoolbar", "Result: " + result_id);

        FragmentManager fragmentManager = getSupportFragmentManager();
        Bundle args = new Bundle();
        args.putString("name", query);
        Fragment fragment = new ResultFragment();
        fragment.setArguments(args);
        fragmentManager.beginTransaction().replace(R.id.main_fragment_container, fragment).commit();
    }
}

From source file:can.yrt.onebusaway.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
        /*//  ww w  .j a  v  a  2s .com
        Intent wordIntent = new Intent(this, WordActivity.class);
        wordIntent.setData(intent.getData());
        startActivity(wordIntent);
        finish();
        */
    } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // handles a search query
        String query = intent.getStringExtra(SearchManager.QUERY);
        doSearch(query);
    }
}

From source file:com.pindroid.activity.FragmentBaseActivity.java

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

    app = (PindroidApplication) getApplicationContext();

    mAccountManager = AccountManager.get(this);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setHomeButtonEnabled(true);
    }/*from  w  w  w .  ja  v a 2 s .c  om*/

    Intent intent = getIntent();

    if (Intent.ACTION_SEARCH.equals(intent.getAction()) && !intent.hasExtra("MainSearchResults")) {
        if (intent.hasExtra("username"))
            app.setUsername(intent.getStringExtra("username"));

        if (intent.hasExtra(SearchManager.QUERY)) {
            //Intent i = new Intent(this, MainSearchResults.class);
            //i.putExtras(intent.getExtras());
            //startActivity(i);
            //finish();
        } else {
            onSearchRequested();
        }
    }

    //init();
}

From source file:com.bdenney.locl.activity.NearbyActivity.java

private String getSearchTerm() {
    String query = null;/*from  ww w .ja va  2 s.  com*/
    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        query = intent.getStringExtra(SearchManager.QUERY);
    }
    return Strings.nullToEmpty(query);
}

From source file:org.maikelwever.droidpile.SearchActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        this.searchQuery = intent.getStringExtra(SearchManager.QUERY);
        doSearch();/*from ww w. j  a v a  2 s. c  o m*/
    } else if (!this.searchQuery.isEmpty()) {
        doSearch();
    }
}

From source file:com.yeldi.yeldibazaar.SearchResults.java

@Override
public void onCreate(Bundle savedInstanceState) {

    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("lightTheme", false))
        setTheme(R.style.AppThemeLight);

    super.onCreate(savedInstanceState);
    ActionBarCompat.create(this).setDisplayHomeAsUpEnabled(true);
    applist = new AvailableAppListAdapter(this);
    setContentView(R.layout.searchresults);

    // Start a search by just typing
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    Intent intent = getIntent();/* ww w  .jav  a2  s.c o  m*/

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

    updateView();
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_find_visits);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mSpinner = (ProgressBar) findViewById(R.id.visitsListViewLoading);
    mVisitsListView = (ListView) findViewById(R.id.visitsListView);
    mEmptyList = (TextView) findViewById(R.id.emptyVisitsListViewLabel);
    mEmptyList.setText(getString(R.string.search_visits_no_results));
    mVisitsListView.setEmptyView(mEmptyList);

    FontsUtil.setFont((ViewGroup) findViewById(android.R.id.content));
    if (getIntent().getAction() == null) {
        getIntent().setAction(Intent.ACTION_SEARCH);
        handleIntent(getIntent());/*from ww w.  j  a v a2  s  .  c om*/
    } else if (mAdapter != null) {
        mVisitsListView.setAdapter(mAdapter);
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_find_visits);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mSpinner = (ProgressBar) findViewById(R.id.visits_list_view_loading);
    mVisitsListView = (ListView) findViewById(R.id.visits_list_view);
    mEmptyList = (TextView) findViewById(R.id.empty_visits_list_view);
    mEmptyList.setText(getString(R.string.search_visits_no_results));
    mVisitsListView.setEmptyView(mEmptyList);

    FontsUtil.setFont((ViewGroup) findViewById(android.R.id.content));
    if (getIntent().getAction() == null) {
        getIntent().setAction(Intent.ACTION_SEARCH);
        handleIntent(getIntent());/*from  w w  w.  ja  v a2s.c  o m*/
    } else if (mAdapter != null) {
        mVisitsListView.setAdapter(mAdapter);
    }
}

From source file:org.onebusaway.android.ui.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
        /*/*from ww  w. j a v a2s  .co  m*/
        Intent wordIntent = new Intent(this, WordActivity.class);
        wordIntent.setData(intent.getData());
        startActivity(wordIntent);
        finish();
        */
    } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // handles a search query
        String query = intent.getStringExtra(SearchManager.QUERY);
        //Analytics
        ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
                getString(R.string.analytics_action_button_press),
                getString(R.string.analytics_label_button_press_search_button));
        doSearch(query);
    }
}

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  v a  2s.co  m*/
        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);
    }
}