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:free.rm.skytube.gui.activities.MainActivity.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_activity_menu, menu);

    // setup the SearchView (actionbar)
    final MenuItem searchItem = menu.findItem(R.id.menu_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getString(R.string.search_videos));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override/* w w w.  j a  v  a2  s. co m*/
        public boolean onQueryTextChange(String newText) {
            return false;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            // collapse the action-bar's search view
            searchView.setQuery("", false);
            searchView.setIconified(true);
            menu.findItem(R.id.menu_search).collapseActionView();

            // run the search activity
            Intent i = new Intent(MainActivity.this, SearchActivity.class);
            i.setAction(Intent.ACTION_SEARCH);
            i.putExtra(Intent.ACTION_SEARCH, query);
            startActivity(i);

            return true;
        }
    });

    return true;
}

From source file:org.barbon.mangaget.MangaSearch.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        getMangaSearchResults().performSearch(intent);
    }
}

From source file:com.aptoide.amethyst.ui.MoreListViewItemsActivity.java

@Override
public void startActivity(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        intent.putExtra(SearchActivity.SEARCH_SOURCE, storeName);
        intent.putExtra(SearchActivity.SEARCH_THEME, storeTheme);
    }//from w  w w .java2  s  . co  m
    super.startActivity(intent);
}

From source file:com.jackleeentertainment.oq.ui.layout.activity.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    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_contactlist);

    // Check if two pane bool is set based on resource directories
    isTwoPaneLayout = false;//from   w  ww  .j a  va  2 s . co  m

    // 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 = App.getContext().getResources().getString(R.string.contacts_list_search_results_title)
                + " " + searchQuery;
        setTitle(title);
    }

}

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

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

    mSpinner = (ProgressBar) findViewById(R.id.patientListViewLoading);
    mPatientsListView = (ListView) findViewById(R.id.patientListView);
    mEmptyList = (TextView) findViewById(R.id.emptyPatientListView);

    FontsUtil.setFont((ViewGroup) findViewById(android.R.id.content));
    if (getIntent().getAction() == null || searching) {
        getIntent().setAction(Intent.ACTION_SEARCH);
        handleIntent(getIntent());//from   w w  w .  j a v a  2  s  .c om
    } else if (mAdapter != null) {
        mPatientsListView.setAdapter(mAdapter);
        if (mAdapter.getCount() == 0) {
            mEmptyList.setText(getString(R.string.search_patient_no_result_for_query, mLastQuery));
            mPatientsListView.setEmptyView(mEmptyList);
        }
    }
}

From source file:com.lokation.contacts2.ui.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    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.// w ww  .  j  av  a2 s .co  m
    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.deliciousdroid.fragment.MainSearchResultsFragment.java

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

    base = (FragmentBaseActivity) getActivity();
    base.setTitle(R.string.main_search_results_title);

    String[] MENU_ITEMS = new String[] { getString(R.string.search_results_bookmark),
            getString(R.string.search_results_tag), getString(R.string.search_results_global_tag) };

    setListAdapter(new ArrayAdapter<String>(base, R.layout.main_view, MENU_ITEMS));

    final Intent intent = base.getIntent();

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        if (intent.hasExtra(SearchManager.QUERY)) {
            Intent i = new Intent(base, MainSearchResultsFragment.class);
            i.putExtras(intent.getExtras());
            startActivity(i);/*ww  w .  j av a 2  s . co m*/
            base.finish();
        } else {
            base.onSearchRequested();
        }
    } else if (Intent.ACTION_VIEW.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);
            base.finish();
        } else if (path.contains("bookmarks") && TextUtils.isDigitsOnly(data.getLastPathSegment())) {
            Intent viewBookmark = new Intent(base, ViewBookmark.class);
            viewBookmark.setData(data);

            Log.d("View Bookmark Uri", data.toString());
            startActivity(viewBookmark);
            base.finish();
        } else if (tagname != null) {
            Intent viewTags = new Intent(base, BrowseBookmarks.class);
            viewTags.setData(data);

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

    ListView lv = getListView();
    lv.setTextFilterEnabled(true);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0) {
                searchActionListener.onBookmarkSearch();
            } else if (position == 1) {
                searchActionListener.onTagSearch();
            } else if (position == 2) {
                searchActionListener.onGlobalTagSearch();
            }
        }
    });
}

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

@Override
protected void onNewIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction()))
        mQuery = intent.getStringExtra(SearchManager.QUERY);
    super.onNewIntent(intent);
    updateView();/*from  ww  w.j ava  2 s .  co m*/
}

From source file:com.dilyar.weather.app.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {

    Log.i(LOG_TAG, "onNewIntent()");
    super.onNewIntent(intent);

    //Verify the action and get the query
    if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
        String inputLocation = intent.getStringExtra(SearchManager.QUERY);

        //Download weather data from server
        SunshineSyncAdapter.syncImmediatelyWithLocationName(this, inputLocation);
        Log.d(LOG_TAG, "Got searching result: " + inputLocation + ". Start syncing");

        Utility.saveCityNameToSP(this, inputLocation, true);
        mPagerAdapter.notifyDataSetChanged();
        mViewPager.setCurrentItem(Utility.getCityNamesSize(this), false);

        if (Utility.getNotificationCity(this) == null) {
            Log.d(LOG_TAG, "MyNotification city was null, set it to new city: " + inputLocation);
            Utility.setNotificationCity(this, inputLocation, true);
        }//from www  . j  a va 2s  .co m

    }
}

From source file:de.androvdr.fragments.TimersFragment.java

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

    mListView = (ListView) mActivity.findViewById(android.R.id.list);

    /*/*  w w w.  ja va 2 s . co m*/
     * setTheme doesn't change background color :(
     */
    if (Preferences.blackOnWhite)
        mListView.setBackgroundColor(Color.WHITE);

    /*
     * perform epgsearch ?
     */
    EpgSearch epgSearch = null;
    Intent intent = mActivity.getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        epgSearch = new EpgSearch();
        epgSearch.search = query.trim();
        epgSearch.inTitle = Preferences.epgsearch_title;
        epgSearch.inSubtitle = Preferences.epgsearch_subtitle;
        epgSearch.inDescription = Preferences.epgsearch_description;
        TextView tv = (TextView) mActivity.findViewById(R.id.header_text);
        tv.setText(epgSearch.search);
        mIsSearch = true;
    }

    mController = new TimerController(mActivity, mHandler, mListView, epgSearch);
    mController.setOnTimerSelectedListener(this);
    mController.isSearch = mIsSearch;

    getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    if (mActivity.isDualPane()) {
        mUpdateSelectedItemThread = new UpdateSelectedItemThread() {
            @Override
            public int getPosition() {
                int position = mCurrentItemIndex;
                if (position == -1 && getListView().getCount() > 0)
                    position = 0;
                return position;
            }
        };
    }
}