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.app_software.chromisstock.ProductListActivity.java

private void askCreateProduct(final String code) {

    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle(getResources().getString(R.string.dlg_new_barcode_title));
    alert.setMessage(getResources().getString(R.string.dlg_new_barcode_message));

    alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            Bundle values = new Bundle();
            values.putString(StockProduct.CODE, code);
            Long id = DatabaseHandler.getInstance(getApplicationContext()).createProduct(values);
            onItemSelected(id);/*from  w  w w .j a  v a2  s .  c om*/
        }
    });

    alert.setNeutralButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            // Use the scanned data in a new search fragment
            Log.v(TAG, "Barcode not in system, starting search");
            Intent i = new Intent(getApplicationContext(), ProductListActivity.class);
            i.putExtra(SearchManager.QUERY, code);
            i.setAction(Intent.ACTION_SEARCH);
            startActivity(i);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
        }
    });

    alert.show();
}

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

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

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

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

From source file:com.coderdojo.libretalk.MainActivity.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  w  w.  j a  v  a2  s .  c om
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_addfriend:
        Fragment fragment = new AddFriendFragment();
        Bundle args = new Bundle();

        FragmentManager fragmentManager = getFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

        return true;

    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.audiokernel.euphonyrmt.SearchActivity.java

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

    setContentView(R.layout.search_results);

    final SearchResultsPagerAdapter adapter = new SearchResultsPagerAdapter();
    final ActionBar actionBar = getSupportActionBar();

    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(adapter);/*w  ww  . j  a v  a2 s  . c  o m*/
    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(final int position) {
            // When swiping between pages, select the corresponding tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mTabArtists = actionBar.newTab().setText(R.string.artists).setTabListener(this);
    actionBar.addTab(mTabArtists);

    mTabAlbums = actionBar.newTab().setText(R.string.albums).setTabListener(this);
    actionBar.addTab(mTabAlbums);

    mTabSongs = actionBar.newTab().setText(R.string.songs).setTabListener(this);
    actionBar.addTab(mTabSongs);

    mListArtistsFrame = findViewById(R.id.list_artists_frame);
    mNoResultArtistsView = mListArtistsFrame.findViewById(R.id.no_artist_result);
    mListArtists = (ListView) mListArtistsFrame.findViewById(android.R.id.list);
    mListArtists.setOnItemClickListener(this);

    mListAlbumsFrame = findViewById(R.id.list_albums_frame);
    mNoResultAlbumsView = mListAlbumsFrame.findViewById(R.id.no_album_result);
    mListAlbums = (ListView) mListAlbumsFrame.findViewById(android.R.id.list);
    mListAlbums.setOnItemClickListener(this);

    mListSongsFrame = findViewById(R.id.list_songs_frame);
    mNoResultSongsView = mListSongsFrame.findViewById(R.id.no_song_result);
    mListSongs = (ListView) mListSongsFrame.findViewById(android.R.id.list);
    mListSongs.setOnItemClickListener(this);

    mLoadingView = findViewById(R.id.loadingLayout);
    mLoadingView.setVisibility(View.VISIBLE);

    final Intent queryIntent = getIntent();
    final String queryAction = queryIntent.getAction();

    if (Intent.ACTION_SEARCH.equals(queryAction) || PLAY_SERVICES_ACTION_SEARCH.equals(queryAction)) {
        mSearchKeywords = queryIntent.getStringExtra(SearchManager.QUERY).trim();
        final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                SearchRecentProvider.AUTHORITY, SearchRecentProvider.MODE);
        suggestions.saveRecentQuery(mSearchKeywords, null);
    } else {
        return; // Bye !
    }

    setTitle(getTitle() + " : " + mSearchKeywords);

    registerForContextMenu(mListArtists);
    registerForContextMenu(mListAlbums);
    registerForContextMenu(mListSongs);

    updateList();
    actionBar.setDisplayHomeAsUpEnabled(true);
}

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

/**
 * @param event/*from   w w  w  .  j a va 2s. 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) getActionBarActivity();
    m.showDetails(f, true);
}

From source file:ru.besttuts.stockwidget.ui.SearchableQuoteActivity.java

private void handleIntent(Intent intent) {

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        Bundle data = new Bundle();
        data.putString("query", intent.getStringExtra(SearchManager.QUERY));
        getSupportLoaderManager().restartLoader(URL_LOADER, data, this);
    }// w w w .  ja  va  2  s. c o m
    if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        // Handle a suggestions click (because the suggestions all use ACTION_VIEW)
        Uri data = intent.getData();
        Result result = SymbolProvider.tempMap.get(data.getPath().substring("/symbols/".length()));
        if (null != mDataSource) {
            mDataSource.addQuoteRec(result);
        }
        LOGD(TAG, "handleIntent(Intent.ACTION_VIEW): " + data);

        searchView.setQuery("", false);
        searchView.clearFocus();
        // intent.getExtras().getString(SearchManager.EXTRA_DATA_KEY)
        //            showResult(data);
    }
}

From source file:com.hybris.mobile.app.commerce.fragment.CatalogContentFragmentBase.java

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

    // Coming from a search request
    if (isSearchRequest()) {
        resetData();//from   www. j av  a 2  s  .  co m

        Intent intent = getActivity().getIntent();

        mCurrentSearchText = intent.getStringExtra(SearchManager.QUERY);
    }

    // Updating product list
    updateProductList();
}

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

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