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:cn.androidy.swiftlib.navigationdrawer.NavigationDrawerActivity.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 ww  .  j  ava 2s . co  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, 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:com.smedic.tubtub.Pane.java

/**
 * Handle search intent and queries YouTube for videos
 *
 * @param intent//ww  w.java 2 s .co  m
 */
private void handleIntent(Intent intent) {
    final String action = intent.getAction();

    if (action.equals(Intent.ACTION_SEARCH)) {
        String query = intent.getStringExtra(SearchManager.QUERY);

        viewPager.setCurrentItem(Pane.SEARCH.ordinal(), true); //switch to search fragment

        if (searchFragment != null)
            searchFragment.searchQuery(query);
        if (playlistsFragment != null)
            playlistsFragment.searchQuery(query);

    } else if (action.equals(Intent.ACTION_SEND)) {
        final String url = intent.getStringExtra(Intent.EXTRA_TEXT);
        Log.d(TAG, "Intent received: " + url);

        final String id = Utils.extractId(url);
        if (id == null)
            return;

        if (url.contains("playlist")) {
            viewPager.setCurrentItem(Pane.PLAYLIST.ordinal(), true);
            playlistsFragment.searchId(id);

        } else if (searchFragment != null) {
            viewPager.setCurrentItem(Pane.SEARCH.ordinal(), true);
            searchFragment.searchId(id);
        }
    }
}

From source file:co.tinode.tindroid.ContactsFragment.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);/*from ww  w  .ja v  a  2s.c  o m*/

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

    mContactsLoaderCallback = new ContactsLoaderCallback();
    mPhEmImLoaderCallback = new PhEmImLoaderCallback();

    /*
     * 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(),
            getActivity().getSupportFragmentManager()) {
        @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_person_circle);
}

From source file:org.mixare.MixListView.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        getRouteSuggestions(query);/*w  ww. j  a  va2 s .c  o m*/
    }
}

From source file:ch.citux.td.ui.TDActivity.java

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

        if (searchFragment == null) {
            searchFragment = new SearchFragment();
        }//from   w  w w . jav a2 s.c om
        searchFragment.setQuery(query);
        searchFragment.loadData();

        replaceFragment(searchFragment);
        Log.d(this, query);
    }
}

From source file:com.kawakawaplanning.rssreader.Main.MainActivity.java

public void browser(View v) {
    Vibrator vib = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    vib.vibrate(50);//w  w w .ja v  a  2  s. c  o m
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, "RSS ????");
    startActivity(intent);
}

From source file:com.example.tobias.androidtestapp.navigationdrawer.NavigationDrawerMain.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;
    }// w  w  w  .j av a 2 s.com
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_websearch:
        // Im Web nach dem Planeten suchen der aktuell angezeigt wird
        Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, getSupportActionBar().getTitle());
        // falls Webbrowser installiert, diesen mit unserem Suchbegriff starten
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        } else {
            // falls kein Webbrowser installiert, Toast machen
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.visva.voicerecorder.view.fragments.FragmentContact.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);/*from  w  w  w  .j  a  va  2s  . 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);
    }

    iHomeActionListener = (ActivityHome) getActivity();
}

From source file:com.sharklee.navigationDrawer.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // mDrawerToggleup???true???
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }/*w  w w. j a  va  2s  .com*/
    // 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, getActionBar().getTitle());
        //??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:util.mediamanager.PlaylistUtils.java

public static void PlaySearchArtist(Context context, String artist) {
    Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
    intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE);
    intent.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artist);
    intent.putExtra(SearchManager.QUERY, artist);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    if (intent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(intent);/*from  w  ww . j a  va2  s  .  c  om*/
    }
}