Example usage for android.app SearchManager QUERY

List of usage examples for android.app SearchManager QUERY

Introduction

In this page you can find the example usage for android.app SearchManager QUERY.

Prototype

String QUERY

To view the source code for android.app SearchManager QUERY.

Click Source Link

Document

Intent extra data key: Use this key with android.content.Intent#getStringExtra content.Intent.getStringExtra() to obtain the query string from Intent.ACTION_SEARCH.

Usage

From source file:com.vnapnic.streamgames.ui.TDActivity.java

@Override
protected void onNewIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        setTitle(R.string.search_title);
        String query = intent.getStringExtra(SearchManager.QUERY);

        if (searchFragment == null) {
            searchFragment = new SearchFragment();
        }//from   ww w .ja v a2s  . c o m

        searchFragment.setQuery(query);
        searchFragment.loadData();

        replaceFragment(searchFragment);
    }
}

From source file:com.desitum.landscape_connect.activities.HomeActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // The action bar home/up action should open or close the drawer.
    // ActionBarDrawerToggle will take care of this.
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }//from w w  w .ja  va2  s. co  m
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_settings:
        // create intent to perform web search for this planet
        Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, getActionBar().getTitle());
        // catch event that there's no activity to handle intent
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        } else {
            Toast.makeText(this, "not available", Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.pindroid.fragment.BrowseBookmarkFeedFragment.java

@Override
public void onResume() {
    super.onResume();

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        getActivity().setTitle(getString(R.string.search_results_global_tag_title, query));
    } else if (feed != null && feed.equals("recent")) {
        getActivity().setTitle(getString(R.string.browse_recent_bookmarks_title));
    } else if (feed != null && feed.equals("popular")) {
        getActivity().setTitle(getString(R.string.browse_popular_bookmarks_title));
    } else if (feed != null && feed.equals("network")) {
        getActivity().setTitle(getString(R.string.browse_network_bookmarks_title));
    } else {/*from   w w w.  java 2s. c om*/
        if (tagname != null && tagname != "") {
            getActivity().setTitle(getString(R.string.browse_user_bookmarks_tagged_title, feed, tagname));
        } else {
            getActivity().setTitle(getString(R.string.browse_user_bookmarks_title, feed));
        }
    }
}

From source file:org.freespanish.diccionario.main.MainActivity.java

@Override
public void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        searchFragment.onWordSearched(query);
    }//from   www  .ja va  2  s  .  c o  m
}

From source file:com.jazz.MyActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // The action bar home/up action should open or close the drawer.
    // ActionBarDrawerToggle will take care of this.
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }//from   w w w  . j  av  a2  s  .c om
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_search:
        // create intent to perform web search for this planet
        Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, getActionBar().getTitle());
        // catch event that there's no activity to handle intent
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        } else {
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:br.com.dsasoft.example.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // The action bar home/up action should open or close the drawer.
    // ActionBarDrawerToggle will take care of this.
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }//ww  w. j a  v a 2  s. c  o m
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_websearch:
        // create intent to perform web search for this planet
        Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, getSupportActionBar().getTitle());
        // catch event that there's no activity to handle intent
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        } else {
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.ute.bihapi.wydarzeniatekstowe.thirdScreenActivities.ContactsListFragment.java

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

    // Let this fragment contribute menu items
    setHasOptionsMenu(true);/*w ww  .ja  va  2 s .c  om*/

    // Create the main contacts adapter
    mAdapter = new ContactsAdapter(getActivity());

    if (savedInstanceState != null) {
        // If we're restoring state after this fragment was recreated then
        // retrieve previous search term and previously selected search
        // result.
        mSearchTerm = savedInstanceState.getString(SearchManager.QUERY);
        mPreviouslySelectedSearchItem = savedInstanceState.getInt(STATE_PREVIOUSLY_SELECTED_KEY, 0);
    }
}

From source file:learn2crack.activities.ContactsListFragment.java

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

    // Check if this fragment is part of a two-pane set up or a single pane by reading a
    // boolean from the application resource directories. This lets allows us to easily specify
    // which screen sizes should use a two-pane layout by setting this boolean in the
    // corresponding resource size-qualified directory.
    mIsTwoPaneLayout = false;//getResources().getBoolean(R.bool.has_two_panes);

    // Let this fragment contribute menu items
    setHasOptionsMenu(true);/*from ww w. j  a v  a 2 s.co  m*/

    // Create the main contacts adapter
    mAdapter = new ContactsAdapter(getActivity());

    if (savedInstanceState != null) {
        // If we're restoring state after this fragment was recreated then
        // retrieve previous search term and previously selected search
        // result.
        mSearchTerm = savedInstanceState.getString(SearchManager.QUERY);
        //mPreviouslySelectedSearchItem =
        //        savedInstanceState.getInt(STATE_PREVIOUSLY_SELECTED_KEY, 0);
        //getListView().setOnItemClickListener(this);
    }

    /*
     * An ImageLoader object loads and resizes an image in the background and binds it to the
     * QuickContactBadge in each item layout of the ListView. ImageLoader implements memory
     * caching for each image, which substantially improves refreshes of the ListView as the
     * user scrolls through it.
     *
     * To learn more about downloading images asynchronously and caching the results, read the
     * Android training class Displaying Bitmaps Efficiently.
     *
     * http://developer.android.com/training/displaying-bitmaps/
     */
    mImageLoader = new ImageLoader(getActivity(), getListPreferredItemHeight()) {
        @Override
        protected Bitmap processBitmap(Object data) {
            // This gets called in a background thread and passed the data from
            // ImageLoader.loadImage().
            if (data instanceof Integer) {
                return loadContactPhotoThumbnail(String.valueOf(data), getImageSize());
            }
            return loadContactPhotoThumbnail((String) data, getImageSize());
        }
    };

    // Set a placeholder loading image for the image loader
    mImageLoader.setLoadingImage(R.drawable.ic_contact_picture_holo_light);
    // Add a cache to the image loader
    mImageLoader.addImageCache(getActivity().getSupportFragmentManager(), 0.1f);
    mHasWN = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
}

From source file:fr.matthiasbosc.translucentmap.MainActivity.java

private void handleIntent(Intent intent) {
    if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
        doSearch(intent.getStringExtra(SearchManager.QUERY));
    } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {
        getPlace(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
    }//  w  w  w .  java  2 s .  c  o  m
}

From source file:com.andrada.sitracker.ui.SearchActivity.java

@Override
protected void onNewIntent(Intent intent) {
    LOGD(TAG, "SearchActivity.onNewIntent: " + intent);
    setIntent(intent);//from w w  w. j  a v  a2  s.  c om
    String query = intent.getStringExtra(SearchManager.QUERY);
    Bundle args = intentToFragmentArguments(
            new Intent(Intent.ACTION_VIEW, AppUriContract.buildSamlibSearchUri(query, 0)));
    if (mAuthorsFragment != null) {
        mAuthorsFragment.reloadFromArguments(args);
    }
}