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.forktech.cmerge.ui.ContactsListFragment.java

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

    mContactList = new ArrayList<Integer>();

    // 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;//w  w  w .  j  av  a2  s .  co  m

    // Let this fragment contribute menu items
    setHasOptionsMenu(true);

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

    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);
        mAdapter.setSearchTerm(savedInstanceState.getString(SearchManager.QUERY));
        mPreviouslySelectedSearchItem = savedInstanceState.getInt(STATE_PREVIOUSLY_SELECTED_KEY, 0);
    }

    /*
     * 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().
            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);
}

From source file:br.com.mybaby.contatos.ContactsListFragment.java

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

    contatoDAO = new ContatoDAO(getActivity());

    extraSMSTel = getActivity().getIntent().getStringExtra(Constantes.EXTRA_TIPO_CONTATO);

    // 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 = getResources().getBoolean(R.bool.has_two_panes);

    // Let this fragment contribute menu items
    setHasOptionsMenu(true);/*from   www .ja va2  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);
    }

    /*
     * 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().
            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);
}

From source file:it.iziozi.iziozi.gui.IORemoteImageSearchActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        searchImages(query);//  w  w  w  . j  av a  2  s. co  m
    }
}

From source file:robert843.o2.pl.player.ui.PlaceholderActivity.java

@Override
protected void onMediaControllerConnected() {
    if (mVoiceSearchParams != null) {
        // If there is a bootstrap parameter to start from a search query, we
        // send it to the media session and set it to null, so it won't play again
        // when the activity is stopped/started or recreated:
        String query = mVoiceSearchParams.getString(SearchManager.QUERY);
        getMediaController().getTransportControls().playFromSearch(query, mVoiceSearchParams);
        mVoiceSearchParams = null;/*w  ww.j  av a2s  .  c  om*/
    }
    getBrowseFragment().onConnected();
}

From source file:com.benlinskey.greekreference.MainActivity.java

/**
 * Processes an <code>Intent</code> if it can be handled by this {@code Activity} or
 * throws an exception if this {@code Activity} cannot handle the specified {@code Intent}.
 * @param intent the {@code Intent} to handle
 *///  ww w .jav  a  2s .co  m
void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra((SearchManager.QUERY));
        search(query);
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri data = intent.getData();
        getLexiconEntry(data);
    } else if (ACTION_SET_MODE.equals(intent.getAction())) {
        String modeName = intent.getStringExtra(KEY_MODE);
        Mode mode = Mode.getModeFromName(modeName);
        switchToMode(mode);
    }
}

From source file:edu.cmu.cylab.starslinger.view.PickRecipientsActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String searchQuery = intent.getStringExtra(SearchManager.QUERY);

        SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                CustomSuggestionsProvider.AUTHORITY, CustomSuggestionsProvider.MODE);
        suggestions.saveRecentQuery(searchQuery, null);
        searchContacts(searchQuery);//from   ww w .j  a  v  a2  s  .c  o m

    }
}

From source file:org.peterbaldwin.vlcremote.fragment.PlaylistFragment.java

private void searchForItem(PlaylistItem item) {
    if (item instanceof Track) {
        Track track = (Track) item;
        String title = track.getTitle();
        String artist = track.getArtist();
        String query = artist + " " + title;

        Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
        intent.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artist);
        intent.putExtra(MediaStore.EXTRA_MEDIA_TITLE, title);
        intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "audio/*");
        intent.putExtra(SearchManager.QUERY, query);

        String chooserTitle = getString(R.string.mediasearch, title);
        startActivity(Intent.createChooser(intent, chooserTitle));
    }//w  w  w  . j a va  2s  .c  o  m
}

From source file:org.braiden.fpm2.PasswordItemListActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    // if this acitity receives input from search widget, apply the search string a listView text filter
    if (intent.getAction().equals(Intent.ACTION_SEARCH) && getFpmApplication().isCryptOpen()) {
        String searchString = intent.getStringExtra(SearchManager.QUERY);
        getListView().setFilterText(searchString);
    }// w w w  .  ja v a 2s  .  c  o  m
}

From source file:org.yammp.app.AlbumFragment.java

private void doSearch() {

    CharSequence title = null;/*from  w  w  w . j a v  a2s. c  o m*/
    String query = null;

    Intent i = new Intent();
    i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    title = mCurrentAlbumName;
    if (MediaStore.UNKNOWN_STRING.equals(mCurrentArtistNameForAlbum)) {
        query = mCurrentAlbumName;
    } else {
        query = mCurrentArtistNameForAlbum + " " + mCurrentAlbumName;
        i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistNameForAlbum);
    }
    if (MediaStore.UNKNOWN_STRING.equals(mCurrentAlbumName)) {
        i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, mCurrentAlbumName);
    }
    i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "audio/*");
    title = getString(R.string.mediasearch, title);
    i.putExtra(SearchManager.QUERY, query);

    startActivity(Intent.createChooser(i, title));
}

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

public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        return new LoaderDrone(base, "global", query);
    } else if (username.equals("recent")) {
        return new LoaderDrone(base, "recent", null);
    } else if (username.equals("network")) {
        return new LoaderDrone(base, "network", null);
    } else {/*from  w ww. jav a 2  s.c  om*/
        return new LoaderDrone(base, username, tagname);
    }
}