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.ifeel.mt.ui.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();//from w  w w  .  ja  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.activity_main);
    this.setTitle(R.string.activity_contacts_list_title);
    // 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.gm.goldencity.activity.search.SearchActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);/*w ww .  j  av  a2  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:fr.eoidb.activity.ItemAttributesListActivity.java

/** Called when the activity is first created. */
@Override//from   w  w w .  ja  v a2 s  .co  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 {
        // 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.jaspersoft.android.jaspermobile.activities.repository.fragment.SearchControllerFragment.java

@Override
public boolean onQueryTextSubmit(String query) {
    searchMenuItem.collapseActionView();
    String resourceUri = getResourceUri();
    Intent searchIntent = SearchableActivity_.intent(getActivity()).query(query).resourceUri(resourceUri)
            .resourceTypes(resourceTypes).get();
    searchIntent.setAction(Intent.ACTION_SEARCH);
    startActivity(searchIntent);// w  ww. j av  a2s  .  c om
    return true;
}

From source file:com.appsol.sharewithcontact.ui.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        // Utils.enableStrictMode();
    }//from w w w . j a v a  2s  .  com
    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_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:com.android.mail.ui.TwoPaneController.java

/**
 * Display the conversation list fragment.
 *//*from   w w  w  . j a  v  a  2 s .c  om*/
private void initializeConversationListFragment() {
    if (Intent.ACTION_SEARCH.equals(mActivity.getIntent().getAction())) {
        if (shouldEnterSearchConvMode()) {
            mViewMode.enterSearchResultsConversationMode();
        } else {
            mViewMode.enterSearchResultsListMode();
        }
    }
    renderConversationList();
}

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

/**
 * Getting intent search query/*  w  w  w.  java2s  .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:edu.umbc.cs.ebiquity.mithril.parserapp.contentparsers.contacts.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();//ww  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.activity_contact_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: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();/* ww w . j a va 2s .c o  m*/
        if (mFindActiveVisitItem != null) {
            MenuItemCompat.collapseActionView(mFindActiveVisitItem);
        }
    }
}

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

@Override
@TargetApi(14)// w  w w.  j  av a 2 s.  c o m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = this;
    mAccountManager = AccountManager.get(this);
    settings = PreferenceManager.getDefaultSharedPreferences(this);

    loadSettings();
    init();

    if (android.os.Build.VERSION.SDK_INT >= 14) {
        getActionBar().setHomeButtonEnabled(true);
    }

    Intent intent = getIntent();

    if (Intent.ACTION_SEARCH.equals(intent.getAction()) && !intent.hasExtra("MainSearchResults")) {
        if (intent.hasExtra(SearchManager.QUERY)) {
            Intent i = new Intent(this, MainSearchResults.class);
            i.putExtras(intent.getExtras());
            startActivity(i);
            finish();
        } else {
            onSearchRequested();
        }
    } else if (Constants.ACTION_SEARCH_SUGGESTION.equals(intent.getAction())) {
        Uri data = intent.getData();
        String path = null;
        String tagname = null;

        if (data != null) {
            path = data.getPath();
            tagname = data.getQueryParameter("tagname");
        }

        if (data.getScheme() == null || !data.getScheme().equals("content")) {
            Intent i = new Intent(Intent.ACTION_VIEW, data);
            startActivity(i);
            finish();
        } else if (path.contains("bookmarks") && TextUtils.isDigitsOnly(data.getLastPathSegment())
                && intent.hasExtra(SearchManager.USER_QUERY)) {
            Intent viewBookmark = new Intent(this, ViewBookmark.class);
            viewBookmark.setAction(Intent.ACTION_VIEW);
            viewBookmark.setData(data);
            viewBookmark.removeExtra(SearchManager.USER_QUERY);
            Log.d("View Bookmark Uri", data.toString());
            startActivity(viewBookmark);
            finish();
        } else if (tagname != null) {
            Intent viewTags = new Intent(this, BrowseBookmarks.class);
            viewTags.setData(data);

            Log.d("View Tags Uri", data.toString());
            startActivity(viewTags);
            finish();
        }
    }
}