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:ca.rmen.android.poetassistant.main.dictionaries.search.Search.java

/**
 * Adds the given suggestions to the search history, in a background thread.
 *//*from  w w w  .  j  ava 2s  .  com*/
@MainThread
public void addSuggestions(String... suggestions) {
    new AsyncTask<String, Void, Void>() {

        @Override
        protected Void doInBackground(String... searchTerms) {
            ContentValues[] contentValues = new ContentValues[suggestions.length];
            for (int i = 0; i < suggestions.length; i++) {
                ContentValues contentValue = new ContentValues(1);
                contentValue.put(SearchManager.QUERY, suggestions[i]);
                contentValues[i] = contentValue;
            }
            mContext.getContentResolver().bulkInsert(SuggestionsProvider.CONTENT_URI, contentValues);
            return null;
        }
    }.execute(suggestions);
}

From source file:com.bayapps.android.robophish.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);
        getSupportMediaController().getTransportControls().playFromSearch(query, mVoiceSearchParams);
        mVoiceSearchParams = null;//from  w w  w  . j  a  v a2s.c  om
    }
    getBrowseFragment().onConnected();
}

From source file:org.geometerplus.android.fbreader.BookmarkFragmentActivity.java

@Override
protected void onNewIntent(Intent intent) {
    OrientationUtil.setOrientation(this, intent);

    if (!Intent.ACTION_SEARCH.equals(intent.getAction())) {
        return;//  w  w  w .j  a v  a 2  s  .c  o  m
    }
    String pattern = intent.getStringExtra(SearchManager.QUERY);
    myBookmarkSearchPatternOption.setValue(pattern);

    final LinkedList<Bookmark> bookmarks = new LinkedList<Bookmark>();
    pattern = pattern.toLowerCase();
    for (Bookmark b : myAllBooksAdapter.bookmarks()) {
        if (MiscUtil.matchesIgnoreCase(b.getText(), pattern)) {
            bookmarks.add(b);
        }
    }
    if (!bookmarks.isEmpty()) {
        showSearchResultsTab(bookmarks);
    } else {
        UIUtil.showErrorMessage(this, "quoteNotFound");
    }
}

From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java

public void searchOnMainActivity(String query) {
    Intent intent = MainActivity_.intent(activity).get();
    intent.putExtra(SearchManager.QUERY, query);
    intent.setAction(Intent.ACTION_SEARCH);
    activity.startActivity(intent);/*from  w ww .  j a  v a  2 s  .c  o m*/
}

From source file:com.example.contactslist.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);/*  w ww  .  ja  v a 2s  .c o m*/

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

    if (dbHelper == null)
        dbHelper = new AppContactsHelper(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);

    //Setup the handler
    //mHandler = new Handler(Looper.getMainLooper());

    Intent lIntent = new Intent(getActivity(), StringAppService.class);
    // Initialize a new Messenger and pass it to service
    mContactListMessenger = new Messenger(new IncomingHandler());
    lIntent.putExtra("Messenger", mContactListMessenger);
    getActivity().startService(lIntent);
}

From source file:edu.umbc.cs.ebiquity.mithril.parserapp.contentparsers.contacts.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);/*w  w w .j a v  a2  s.c om*/

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

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

From source file:com.murati.oszk.audiobook.ui.MusicPlayerActivity.java

protected void initializeFromParams(Bundle savedInstanceState, Intent intent) {
    String mediaId = null;/*from  w ww . ja v a 2 s  . c o m*/

    String action = intent.getAction();
    Bundle extras = intent.getExtras();

    if (action != null) {
        switch (action) {
        case Intent.ACTION_SEARCH:
        case MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH:
            LogHelper.d(TAG, "Starting Search Handler");
            mSearchParams = intent.getExtras();

            mediaId = MediaIDHelper.createMediaID(mSearchParams.getString(SearchManager.QUERY),
                    MediaIDHelper.MEDIA_ID_BY_SEARCH);

            LogHelper.d(TAG, "Search query=", mediaId);
            break;

        case Intent.ACTION_VIEW:
            if (extras != null)
                mediaId = extras.getString(MediaIDHelper.EXTRA_MEDIA_ID_KEY);
            LogHelper.d(TAG, "MediaId fetched=", mediaId);
            break;

        case Intent.ACTION_MAIN:
        default:
            break;
        }
    } else {
        if (savedInstanceState != null) {
            // If there is a saved media ID, use it
            mediaId = savedInstanceState.getString(MediaIDHelper.EXTRA_MEDIA_ID_KEY);
        }
    }
    navigateToBrowser(mediaId);
}

From source file:com.vyasware.vaani.MainActivity.java

private void performAction(String input) {

    String[] verbs = { "", "", "", "?", "",
            "?", "", "", "", "",
            "", "", "", "", "", "weather",
            "?", "?", "", "", "?" };
    String[] actions = { "call", "call", "call", "call", "msg", "msg", "msg", "msg", "open", "open", "open",
            "weather", "weather", "weather", "weather", "weather", "greet", "greet", "greet", "greet",
            "greet" };
    String[] sentence = input.split(" ");
    String action = "", noun = "", result = "";
    int verbindex = -1, nounindex = -1;
    for (String word : sentence) {

        //out.println(word);

        for (int i = 0; i < verbs.length; i++) {
            //System.out.println(verbs[i]);
            if (word.equalsIgnoreCase(verbs[i]))
                verbindex = i;/*  w ww  . j  a  v a  2s.c  o  m*/
        }

        if (verbindex >= 0) {
            //   out.println("true");
            action = actions[verbindex];
            System.out.println(action);
            break;
        }

    }
    for (int j = 0; j < sentence.length; j++) {

        if (sentence[j].equalsIgnoreCase("")) {
            nounindex = j - 1;
        }
    }
    if (nounindex >= 0)
        noun = sentence[nounindex];
    String search = "google!";
    if (action.equals("")/*||noun.equals("")*/) {
        tts.speak(search, TextToSpeech.QUEUE_FLUSH, null);
        Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, returnedText.getText());
        if (intent.resolveActivity(getPackageManager()) != null)
            startActivity(intent);
    } else if (action.equals("call"))
        doCall(noun);
    else if (action.equals("msg"))
        doMsg(noun);
    else if (action.equals("open"))
        doOpen(sentence);
    else if (action.equals("weather"))
        doWeather();
    else if (action.equals("greet"))
        doGreet();
    // tts.speak(result,TextToSpeech.QUEUE_FLUSH, null);

}

From source file:ca.spencerelliott.mercury.Changesets.java

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

    this.requestWindowFeature(Window.FEATURE_PROGRESS);
    this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.changesets);

    //Cancel any notifications previously setup
    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(1);/*from  w  w  w  . ja  v a  2s  .c o m*/

    //Create a new array list for the changesets
    changesets_list = new ArrayList<Map<String, ?>>();
    changesets_data = new ArrayList<Beans.ChangesetBean>();

    //Get the list view to store the changesets
    changesets_listview = (ListView) findViewById(R.id.changesets_list);

    TextView empty_text = (TextView) findViewById(R.id.changesets_empty_text);

    //Set the empty view
    changesets_listview.setEmptyView(empty_text);

    //Use a simple adapter to display the changesets based on the array list made earlier
    changesets_listview.setAdapter(new SimpleAdapter(this, changesets_list, R.layout.changeset_item,
            new String[] { COMMIT, FORMATTED_INFO },
            new int[] { R.id.changesets_commit, R.id.changesets_info }));

    //Set the on click listener
    changesets_listview.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {
            Intent intent = new Intent(Changesets.this, ChangesetViewer.class);

            //Pass the changeset information to the changeset viewer
            Bundle params = new Bundle();
            params.putString("changeset_commit_text", changesets_data.get(position).getTitle());
            params.putString("changeset_changes", changesets_data.get(position).getContent());
            params.putLong("changeset_updated", changesets_data.get(position).getUpdated());
            params.putString("changeset_authors", changesets_data.get(position).getAuthor());
            params.putString("changeset_link", changesets_data.get(position).getLink());
            //params.putBoolean("is_https", is_https);

            intent.putExtras(params);

            startActivity(intent);
        }

    });

    //Register the list view for opening the context menu
    registerForContextMenu(changesets_listview);

    //Get the intent passed by the program
    if (getIntent() != null) {
        //Check to see if this is a search window
        if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
            //Change the title of the activity and the empty text of the list so it looks like a search window
            this.setTitle(R.string.search_results_label);
            empty_text.setText(R.string.search_results_empty);

            //Retrieve the query the user entered
            String query = getIntent().getStringExtra(SearchManager.QUERY);

            //Convert the query to lower case
            query = query.toLowerCase();

            //Retrieve the bundle data
            Bundle retrieved_data = getIntent().getBundleExtra(SearchManager.APP_DATA);

            //If the bundle was passed, grab the changeset data
            if (retrieved_data != null) {
                changesets_data = retrieved_data
                        .getParcelableArrayList("ca.spencerelliott.mercury.SEARCH_DATA");
            }

            //If we're missing changeset data, stop here
            if (changesets_data == null)
                return;

            //Create a new array list to store the changesets that were a match
            ArrayList<Beans.ChangesetBean> search_beans = new ArrayList<Beans.ChangesetBean>();

            //Loop through each changeset
            for (Beans.ChangesetBean b : changesets_data) {
                //Check to see if any changesets match
                if (b.getTitle().toLowerCase().contains(query)) {
                    //Get the title and date of the commit
                    String commit_text = b.getTitle();
                    Date commit_date = new Date(b.getUpdated());

                    //Add a new changeset to display in the list view
                    changesets_list.add(createChangeset(
                            (commit_text.length() > 30 ? commit_text.substring(0, 30) + "..." : commit_text),
                            b.getRevisionID() + " - " + commit_date.toLocaleString()));

                    //Add this bean to the list of found search beans
                    search_beans.add(b);
                }
            }

            //Switch the changeset data over to the changeset data that was a match
            changesets_data = search_beans;

            //Update the list in the activity
            list_handler.sendEmptyMessage(SUCCESSFUL);

            //Notify the activity that it is a search window
            is_search_window = true;

            //Stop loading here
            return;
        }

        //Get the data from the intent
        Uri data = getIntent().getData();

        if (data != null) {
            //Extract the path in the intent
            String path_string = data.getEncodedPath();

            //Split it by the forward slashes
            String[] split_path = path_string.split("/");

            //Make sure a valid path was passed
            if (split_path.length == 3) {
                //Get the repository id from the intent
                repo_id = Long.parseLong(split_path[2].toString());
            } else {
                //Notify the user if there was a problem
                Toast.makeText(this, R.string.invalid_intent, 1000).show();
            }
        }
    }

    //Retrieve the changesets
    refreshChangesets();
}

From source file:net.reichholf.dreamdroid.fragment.helper.HttpFragmentHelper.java

/**
 * @param event/*from   w  ww.ja  v a2s  .c o m*/
 */
public void findSimilarEvents(ExtendedHashMap event) {
    EpgSearchFragment f = new EpgSearchFragment();
    Bundle args = new Bundle();
    args.putString(SearchManager.QUERY, event.getString(Event.KEY_EVENT_TITLE));
    f.setArguments(args);

    MultiPaneHandler m = (MultiPaneHandler) getAppCompatActivity();
    m.showDetails(f, true);
}