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:org.klnusbaum.udj.RegularSearchActivity.java

protected void onNewIntent(Intent intent) {
    Log.d(TAG, "In on new intent");
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String searchQuery = intent.getStringExtra(SearchManager.QUERY);
        searchQuery = searchQuery.trim();
        getIntent().putExtra(SearchManager.QUERY, searchQuery);
        getSupportLoaderManager().restartLoader(SearchFragment.LIB_SEARCH_LOADER_TAG, null, searchFrag);
    }/*  w  w w  .j a  va 2 s.  c o  m*/
}

From source file:com.dmbstream.android.activity.SearchResultsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();//from w w w.  j a v  a 2  s  .c o  m

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        query = intent.getStringExtra(SearchManager.QUERY);
    } else {
        query = intent.getStringExtra(Constants.EXTRA_QUERY_TERM);
        Log.d(TAG, "Query from other intent: " + query);
    }

    // After setting up variables so that they can be accessed in getApiUrl
    // which is called at the end of super.onCreate
    super.onCreate(savedInstanceState);

    // Push the search box into the layout group below the logo bar and above
    // the 'search results' title bar
    ViewGroup container = (ViewGroup) findViewById(R.id.TitleGroup);
    container.addView(ViewGroup.inflate(this, R.layout.partial_search_box, null), 0);
    searchBox = (EditText) findViewById(R.id.SearchText);
    searchBox.setText(query);
    searchBox.setOnKeyListener(this);
    ImageButton searchButton = (ImageButton) findViewById(R.id.search_go_button);
    searchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AnalyticsUtil.trackEvent(SearchResultsActivity.this, "SearchResults", "Click", "Search", 0);
            search();
        }
    });

    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null) {
        inputMethodManager.hideSoftInputFromWindow(searchBox.getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

From source file:se.chalmers.watchme.activity.SearchableActivity.java

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

    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction ft = fragmentManager.beginTransaction();

    fragment = new MovieListFragment();
    Bundle b = new Bundle();

    /*/*from ww w.ja  v a2 s.  c  o m*/
     * Get the intent, verify the action and put the query as an argument to
     * the fragment.
     */
    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        setTitle("Result: " + query);

        b.putString(getString(R.string.search), query);
    }

    fragment.setArguments(b);

    ft.add(android.R.id.content, fragment);
    ft.commit();
}

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

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

    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
        searchType = PlayerListFragment.SearchType.NAME_SEARCH;
    } else {/*ww w  .j av a 2 s  . c  om*/
        searchType = PlayerListFragment.SearchType.LOCATION_SEARCH;
    }

    setContentView(R.layout.player_selector);
    setSupportProgressBarIndeterminateVisibility(false);

    pagerAdapter = new PlayerListPagerAdapter(getSupportFragmentManager(), searchType);
    if (searchType == PlayerListFragment.SearchType.NAME_SEARCH) {
        pagerAdapter.setSearchQuery(getIntent().getStringExtra(SearchManager.QUERY));
    }
    pager = (ViewPager) findViewById(R.id.player_selector_pager);
    pager.setAdapter(pagerAdapter);

    TitlePageIndicator titleIndicator = (TitlePageIndicator) findViewById(R.id.titles);
    titleIndicator.setViewPager(pager);

}

From source file:com.nadmm.airports.afd.SearchActivity.java

private void handleIntent() {
    Intent intent = getIntent();/*ww w. j  a v a 2s .  c  o m*/
    String action = intent.getAction();
    if (Intent.ACTION_SEARCH.equals(action)) {
        // Perform the search using user provided query string
        String query = intent.getStringExtra(SearchManager.QUERY);
        showResults(query);
    } else if (Intent.ACTION_VIEW.equals(action)) {
        // User clicked on a suggestion
        Bundle extra = intent.getExtras();
        String siteNumber = extra.getString(SearchManager.EXTRA_DATA_KEY);
        Intent apt = new Intent(this, AirportActivity.class);
        apt.putExtra(Airports.SITE_NUMBER, siteNumber);
        startActivity(apt);
        finish();
    }
}

From source file:com.thelastcrusade.soundstream.SearchActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.content_frame);

    ActionBar bar = getActionBar();//w  ww . ja v a  2 s .  c o  m
    bar.show();

    // Get the intent, verify the action and get the query
    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        query = intent.getStringExtra(SearchManager.QUERY);
    }

    if (savedInstanceState == null) {
        MusicLibraryFragment fragment = getMusicLibraryFragment(query);
        getSupportFragmentManager().beginTransaction().add(R.id.content, fragment).commit();
    }

}

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

protected void onNewIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        list.setEventSearch(new EventListFragment.NameEventSearch(intent.getStringExtra(SearchManager.QUERY)));
    } else {/*from   w  w  w.  ja v a  2 s.  c  o  m*/
        super.onNewIntent(intent);
    }
}

From source file:net.reichholf.dreamdroid.activities.SearchEpgActivity.java

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

    Intent intent = getIntent();// ww w  .ja  v a  2s. c o m

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

}

From source file:com.jackie.searchFunction.MainActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        Cursor cursor = table.getWordMatches(query, null);
        if (cursor != null) {
            // process Cursor and display results
            StringBuilder stringBuilder = new StringBuilder();
            do {/*  w ww .  ja v  a  2  s  .com*/
                stringBuilder.append(cursor.getString(0)).append("-").append(cursor.getString(1)).append("\n");
            } while (cursor.moveToNext());
            cursor.close();
            tvResult.setText(stringBuilder.toString());
        }
    }
}

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

protected void onNewIntent(Intent intent) {
    Log.d(TAG, "In on new intent");
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        searchQuery = intent.getStringExtra(SearchManager.QUERY);
        getIntent().putExtra(SearchManager.QUERY, searchQuery);
        searchFrag.setSearchQuery(searchQuery);
    }/*from   w  w w  .j  a  v a  2s  . co m*/
}