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

    // Let this fragment contribute menu items
    setHasOptionsMenu(true);// ww  w.  ja va 2s.  co  m
    contactvalue = new HashMap<String, String>();
    // 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:net.eledge.android.europeana.gui.activity.HomeActivity.java

private void performSearch(String query) {
    final Intent intent = new Intent(this, SearchActivity.class);
    intent.setAction(Intent.ACTION_SEARCH);
    intent.putExtra(SearchManager.QUERY, query);
    SearchProfile selected = (SearchProfile) mSpinnerProfiles.getSelectedItem();
    if ((selected != null) && (selected.facets != null)) {
        intent.putExtra(SearchManager.USER_QUERY, selected.facets);
    }//from ww  w. jav a2s  .com
    this.startActivity(intent);
}

From source file:com.fastbootmobile.encore.app.fragments.RecognitionFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    RelativeLayout root = (RelativeLayout) inflater.inflate(R.layout.fragment_recognition, container, false);

    // Recognition layout
    mButtonLayout = (LinearLayout) root.findViewById(R.id.llRecognitionButton);
    mRecognitionButton = (AnimatedMicButton) root.findViewById(R.id.btnStartRec);
    mTvStatus = (TextView) root.findViewById(R.id.tvStatus);
    mTvDetails = (TextView) root.findViewById(R.id.tvDetailsText);

    // Result layout
    mCardResult = (CardView) root.findViewById(R.id.cardResult);
    mTvAlbum = (TextView) root.findViewById(R.id.tvAlbumName);
    mTvArtist = (TextView) root.findViewById(R.id.tvArtistName);
    mTvTitle = (TextView) root.findViewById(R.id.tvTrackName);
    mIvArt = (ImageView) root.findViewById(R.id.ivRecognitionArt);
    mSearchButton = (Button) root.findViewById(R.id.btnSearch);

    mTvOfflineError = (TextView) root.findViewById(R.id.tvErrorMessage);
    mTvOfflineError.setText(R.string.error_recognition_unavailable_offline);

    ProviderAggregator aggregator = ProviderAggregator.getDefault();
    mTvOfflineError.setVisibility(aggregator.isOfflineMode() ? View.VISIBLE : View.GONE);

    mRecognitionButton.setOnClickListener(new View.OnClickListener() {
        @Override//from w w w.j  av a2 s. c  om
        public void onClick(View view) {
            if (mActivePrint == null) {
                mActivePrint = new EchoPrint(RecognitionFragment.this);
                mActivePrint.startRecording();
                onRecognitionStartUI();

                // The buffer has a max size of 20 seconds, so we force stop at around 19 seconds
                mHandler.postDelayed(mStopRecognition, 19000);
            } else {
                mHandler.removeCallbacks(mStopRecognition);
                mStopRecognition.run();
            }
        }
    });

    mSearchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent search = new Intent(getActivity(), SearchActivity.class);
            search.setAction(Intent.ACTION_SEARCH);
            search.putExtra(SearchManager.QUERY, mLastResult.ArtistName + " " + mLastResult.TrackName);
            startActivity(search);
        }
    });

    return root;
}

From source file:rocks.stalin.android.app.ui.MusicPlayerActivity.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);
        MediaControllerCompat.getMediaController(this).getTransportControls().playFromSearch(query,
                mVoiceSearchParams);//from  w w  w . jav  a  2  s . c om
        mVoiceSearchParams = null;
    }
    getBrowseFragment().onConnected();
}

From source file:net.ddns.mlsoftlaberge.mlsoft.contacts.ContactsListFragment.java

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

    // Let this fragment contribute menu items
    setHasOptionsMenu(true);//from ww  w  . j  a v a2 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);
    }

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

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
    starred = sharedPref.getBoolean("pref_key_starred", true);
    if (starred)
        starredfind = 1;
    else
        starredfind = 0;

}

From source file:com.torrenttunes.android.ui.MusicPlayerActivity.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);
        final MediaControllerCompat mediaController = getSupportMediaController();
        if (mediaController != null) {
            mediaController.getTransportControls().playFromSearch(query, mVoiceSearchParams);
        }//from   w w  w  .  j a v  a2  s  . co m
        mVoiceSearchParams = null;
    }
    getBrowseFragment().onConnected();
}

From source file:org.yammp.fragment.QueryFragment.java

public void onServiceConnected(ComponentName name, IBinder service) {

    Bundle bundle = getArguments();//  ww w . ja v a  2  s. co m

    String action = bundle != null ? bundle.getString(INTENT_KEY_ACTION) : null;
    String data = bundle != null ? bundle.getString(INTENT_KEY_DATA) : null;

    if (Intent.ACTION_VIEW.equals(action)) {
        // this is something we got from the search bar
        Uri uri = Uri.parse(data);
        if (data.startsWith("content://media/external/audio/media/")) {
            // This is a specific file
            String id = uri.getLastPathSegment();
            long[] list = new long[] { Long.valueOf(id) };
            mUtils.playAll(list, 0);
            getActivity().finish();
            return;
        } else if (data.startsWith("content://media/external/audio/albums/")) {
            // This is an album, show the songs on it
            Intent i = new Intent(Intent.ACTION_PICK);
            i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
            i.putExtra("album", uri.getLastPathSegment());
            startActivity(i);
            return;
        } else if (data.startsWith("content://media/external/audio/artists/")) {
            // This is an artist, show the albums for that artist
            Intent i = new Intent(Intent.ACTION_PICK);
            i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album");
            i.putExtra("artist", uri.getLastPathSegment());
            startActivity(i);
            return;
        }
    }

    mFilterString = bundle != null ? bundle.getString(SearchManager.QUERY) : null;
    if (MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action)) {
        String focus = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_FOCUS) : null;
        String artist = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_ARTIST) : null;
        String album = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_ALBUM) : null;
        String title = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_TITLE) : null;
        if (focus != null) {
            if (focus.startsWith("audio/") && title != null) {
                mFilterString = title;
            } else if (Audio.Albums.ENTRY_CONTENT_TYPE.equals(focus)) {
                if (album != null) {
                    mFilterString = album;
                    if (artist != null) {
                        mFilterString = mFilterString + " " + artist;
                    }
                }
            } else if (Audio.Artists.ENTRY_CONTENT_TYPE.equals(focus)) {
                if (artist != null) {
                    mFilterString = artist;
                }
            }
        }
    }

    mTrackList = getListView();
    mTrackList.setTextFilterEnabled(true);
}

From source file:com.chris.ni.omw.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.

    // Let this fragment contribute menu items
    setHasOptionsMenu(true);/*from   w  w  w  .  ja v  a2 s .c o  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);
    }

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

    // Add a cache to the image loader
    mImageLoader.addImageCache(getActivity().getSupportFragmentManager(), 0.1f);
}

From source file:ca.rmen.android.palidamuerte.app.poem.detail.PoemDetailActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //// w  w w  . ja  va  2  s.co  m
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        Intent intent = new Intent(this, PoemListActivity.class);
        intent.setAction(getIntent().getAction());
        intent.putExtra(SearchManager.QUERY, getIntent().getStringExtra(SearchManager.QUERY));
        intent.putExtra(PoemListActivity.EXTRA_CATEGORY_ID,
                getIntent().getLongExtra(PoemListActivity.EXTRA_CATEGORY_ID, -1));
        NavUtils.navigateUpTo(this, intent);
        return true;
    } else if (id == R.id.action_prev) {
        mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1);
    } else if (id == R.id.action_next) {
        mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1);
    } else if (id == R.id.action_about) {
        Intent intent = new Intent(this, AboutActivity.class);
        startActivity(intent);
    }
    return super.onOptionsItemSelected(item);
}

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

protected void onNewIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String searchQuery = intent.getStringExtra(SearchManager.QUERY);
        searchQuery = searchQuery.trim();
        intent.putExtra(SearchManager.QUERY, searchQuery);
        intent.setClass(this, RegularSearchActivity.class);
        startActivityForResult(intent, 0);
    } else {//ww  w .j a  v  a2s  .c o  m
        super.onNewIntent(intent);
    }
}