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.scooter1556.sms.android.activity.HomeActivity.java

protected void initialiseFromParams(Bundle savedInstanceState, Intent intent) {
    // check if we were started from a "Play XYZ" voice search. If so, we save the extras
    // (which contain the query details) in a parameter, so we can reuse it later, when the
    // MediaSession is connected.
    if (intent.getAction() != null
            && intent.getAction().equals(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)) {
        voiceSearchParams = intent.getExtras();
        Log.d(TAG, "Starting from voice search query=" + voiceSearchParams.getString(SearchManager.QUERY));
    }//  w w  w .  j  a va 2  s. c  o m
}

From source file:org.voidsink.anewjkuapp.fragment.MapFragment.java

@Override
public void handlePendingIntent(Intent intent) {
    super.handlePendingIntent(intent);
    if (intent != null) {
        if (Intent.ACTION_VIEW.equals(intent.getAction())) {
            if (intent.getData() != null) {
                finishSearch(intent.getData());
            } else {
                String query = intent.getStringExtra(SearchManager.QUERY);
                boolean isExactLocation = intent.getBooleanExtra(MainActivity.ARG_EXACT_LOCATION, false);
                doSearch(query, isExactLocation);
            }/*  w ww. j av a  2  s . c o m*/
        } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            if (intent.getData() != null) {
                finishSearch(intent.getData());
            } else {
                String query = intent.getStringExtra(SearchManager.QUERY);
                boolean isExactLocation = intent.getBooleanExtra(MainActivity.ARG_EXACT_LOCATION, false);
                doSearch(query, isExactLocation);
            }
        }
    }
}

From source file:com.xandy.calendar.SearchActivity.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);
    mHandler = new Handler();

    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);

    setContentView(R.layout.search);// w  ww.  j a  v  a2s .c om

    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    mContentResolver = getContentResolver();

    if (mIsMultipane) {
        getActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
    } else {
        getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
    }

    // Must be the first to register because this activity can modify the
    // list of event handlers in it's handle method. This affects who the
    // rest of the handlers the controller dispatches to are.
    mController.registerEventHandler(HANDLER_KEY, this);

    mDeleteEventHelper = new DeleteEventHelper(this, this, false /* don't exit when done */);

    long millis = 0;
    if (icicle != null) {
        // Returns 0 if key not found
        millis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        if (DEBUG) {
            Log.v(TAG, "Restore value from icicle: " + millis);
        }
    }
    if (millis == 0) {
        // Didn't find a time in the bundle, look in intent or current time
        millis = Utils.timeFromIntentInMillis(getIntent());
    }

    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query;
        if (icicle != null && icicle.containsKey(BUNDLE_KEY_RESTORE_SEARCH_QUERY)) {
            query = icicle.getString(BUNDLE_KEY_RESTORE_SEARCH_QUERY);
        } else {
            query = intent.getStringExtra(SearchManager.QUERY);
        }
        if ("TARDIS".equalsIgnoreCase(query)) {
            Utils.tardis();
        }
        initFragments(millis, query);
    }
}

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

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

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        base.setTitle(getString(R.string.search_results_global_tag_title, query));
    } else if (username.equals("recent")) {
        base.setTitle(getString(R.string.browse_recent_bookmarks_title));
    } else if (username.equals("network")) {
        base.setTitle(getString(R.string.browse_network_bookmarks_title));
    } else {//from   w w  w .j a v  a 2  s .  c om
        if (tagname != null && tagname != "") {
            base.setTitle(getString(R.string.browse_user_bookmarks_tagged_title, username, tagname));
        } else {
            base.setTitle(getString(R.string.browse_user_bookmarks_title, username));
        }
    }

    Uri data = base.getIntent().getData();
    if (data != null && data.getUserInfo() != null && data.getUserInfo() != "") {
        username = data.getUserInfo();
    } else if (base.getIntent().hasExtra("username")) {
        username = base.getIntent().getStringExtra("username");
    } else
        username = base.mAccount.name;
}

From source file:com.app_software.chromisstock.ProductListActivity.java

@Override
public void onNewIntent(Intent intent) { //calls twice
    super.onNewIntent(intent);
    Log.v(TAG, "onNewIntent");
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String search = intent.getStringExtra(SearchManager.QUERY);
        Log.v(TAG, "Searching for: " + search);

        m_ListFragment.setSearch(search);
    }/*from ww  w. j  a  v  a  2s .  c o  m*/
}

From source file:com.xorcode.andtweet.TweetListActivity.java

/**
 * Prepare query to the ContentProvider (to the database) and load List of Tweets with data
 * @param queryIntent/*w w  w  .j a  v  a 2  s .c o  m*/
 * @param otherThread This method is being accessed from other thread
 * @param loadOneMorePage load one more page of tweets
 */
protected void queryListData(Intent queryIntent, boolean otherThread, boolean loadOneMorePage) {
    // The search query is provided as an "extra" string in the query intent
    // TODO maybe use mQueryString here...
    String queryString = queryIntent.getStringExtra(SearchManager.QUERY);
    Intent intent = getIntent();

    if (MyLog.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "doSearchQuery; queryString=\"" + queryString + "\"; TimelineType=" + mTimelineType);
    }

    Uri contentUri = Tweets.CONTENT_URI;

    SelectionAndArgs sa = new SelectionAndArgs();
    String sortOrder = Tweets.DEFAULT_SORT_ORDER;
    // Id of the last (oldest) tweet to retrieve 
    long lastItemId = -1;

    if (queryString != null && queryString.length() > 0) {
        // Record the query string in the recent queries suggestions
        // provider
        SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                TimelineSearchSuggestionProvider.AUTHORITY, TimelineSearchSuggestionProvider.MODE);
        suggestions.saveRecentQuery(queryString, null);

        contentUri = Tweets.SEARCH_URI;
        contentUri = Uri.withAppendedPath(contentUri, Uri.encode(queryString));
    }
    intent.putExtra(SearchManager.QUERY, queryString);

    if (!contentUri.equals(intent.getData())) {
        intent.setData(contentUri);
    }

    if (sa.nArgs == 0) {
        // In fact this is needed every time you want to load next page of
        // tweets.
        // So we have to duplicate here everything we set in
        // com.xorcode.andtweet.TimelineActivity.onOptionsItemSelected()
        sa.clear();
        sa.addSelection(Tweets.TWEET_TYPE + " IN (?, ?)", new String[] {
                String.valueOf(Tweets.TIMELINE_TYPE_FRIENDS), String.valueOf(Tweets.TIMELINE_TYPE_MENTIONS) });
        if (mTimelineType == Tweets.TIMELINE_TYPE_FAVORITES) {
            sa.addSelection(AndTweetDatabase.Tweets.FAVORITED + " = ?", new String[] { "1" });
        }
        if (mTimelineType == Tweets.TIMELINE_TYPE_MENTIONS) {
            sa.addSelection(Tweets.MESSAGE + " LIKE ?",
                    new String[] { "%@" + TwitterUser.getTwitterUser().getUsername() + "%" });
        }
    }

    if (!positionRestored) {
        // We have to ensure that saved position will be
        // loaded from database into the list
        lastItemId = getSavedPosition(true);
    }

    int nTweets = 0;
    if (mCursor != null && !mCursor.isClosed()) {
        if (positionRestored) {
            // If position is NOT loaded - this cursor is from other
            // timeline/search
            // and we shouldn't care how much rows are there.
            nTweets = mCursor.getCount();
        }
        if (!otherThread) {
            mCursor.close();
        }
    }

    if (lastItemId > 0) {
        if (sa.nArgs == 0) {
            sa.addSelection("AndTweetDatabase.Tweets.TWEET_TYPE" + " IN (?, ?)" + ")",
                    new String[] { String.valueOf(Tweets.TIMELINE_TYPE_FRIENDS),
                            String.valueOf(Tweets.TIMELINE_TYPE_MENTIONS) });
        }
        sa.addSelection(Tweets._ID + " >= ?", new String[] { String.valueOf(lastItemId) });
    } else {
        if (loadOneMorePage) {
            nTweets += PAGE_SIZE;
        } else if (nTweets < PAGE_SIZE) {
            nTweets = PAGE_SIZE;
        }
        sortOrder += " LIMIT 0," + nTweets;
    }

    // This is for testing pruneOldRecords
    //        try {
    //            FriendTimeline fl = new FriendTimeline(TweetListActivity.this,
    //                    AndTweetDatabase.Tweets.TIMELINE_TYPE_FRIENDS);
    //            fl.pruneOldRecords();
    //
    //        } catch (Exception e) {
    //            e.printStackTrace();
    //        }

    mCursor = getContentResolver().query(contentUri, PROJECTION, sa.selection, sa.selectionArgs, sortOrder);
    if (!otherThread) {
        createAdapters();
    }

}

From source file:edu.cmu.ece.ece551.uis.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // 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);/*from w  w  w. j  ava2s  . c  om*/
        } else {
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.classiqo.nativeandroid_32bitz.ui.MusicPlayerActivity.java

@Override
protected void onMediaControllerConnected() {
    if (mVoiceSearchParams != null) {
        String query = mVoiceSearchParams.getString(SearchManager.QUERY);
        getSupportMediaController().getTransportControls().playFromSearch(query, mVoiceSearchParams);
        mVoiceSearchParams = null;/*  w ww. ja  va 2  s . c o m*/
    }
    getBrowseFragment().onConnected();
}

From source file:com.bayapps.android.robophish.ui.MusicPlayerActivity.java

protected void initializeFromParams(Bundle savedInstanceState, Intent intent) {
    String mediaId = null;/*from   w  ww . j av  a 2  s.  c  o m*/
    // check if we were started from a "Play XYZ" voice search. If so, we save the extras
    // (which contain the query details) in a parameter, so we can reuse it later, when the
    // MediaSession is connected.
    if (intent.getAction() != null
            && intent.getAction().equals(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)) {
        mVoiceSearchParams = intent.getExtras();
        LogHelper.d(TAG, "Starting from voice search query=",
                mVoiceSearchParams.getString(SearchManager.QUERY));
    } else if (intent.getAction() != null && intent.getAction().equals(MediaStore.INTENT_ACTION_MEDIA_SEARCH)) {

        navigateToBrowser(null, null, null);

        Bundle extras = intent.getExtras();
        String title = extras.getString("title");
        String subtitle = extras.getString("subtitle");
        mediaId = extras.getString("showid");

        String year = subtitle.split("-")[0];
        //browse to year...
        navigateToBrowser(null, null, MediaIDHelper.MEDIA_ID_SHOWS_BY_YEAR + "/" + year);

        //now launch as show
        navigateToBrowser(title, subtitle, mediaId);
    }

    else {
        if (savedInstanceState != null) {
            // If there is a saved media ID, use it
            mediaId = savedInstanceState.getString(SAVED_MEDIA_ID);
        }
        navigateToBrowser(null, null, mediaId);
    }
}

From source file:com.googlecode.android_scripting.activity.ApiBrowser.java

@Override
protected void onNewIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        searchResultMode = true;/*w w w  .j a  va  2s  .  c o m*/
        final String query = intent.getStringExtra(SearchManager.QUERY);
        // ((TextView) findViewById(R.id.left_text)).setText(query);
        updateAndFilterMethodDescriptors(query);
        if (mMethodDescriptors.size() == 1) {
            mExpandedPositions.add(0);
        } else {
            mExpandedPositions.clear();
        }
        mAdapter.notifyDataSetChanged();
    }
}