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.tinbytes.simplesearchapp.SimpleListViewActivity.java

private void handleIntent(Intent intent) {
    String query;//from  w w  w. j a v a2s . com
    String intentAction = intent.getAction();
    if (Intent.ACTION_SEARCH.equals(intentAction)) {
        query = intent.getStringExtra(SearchManager.QUERY);
        Bundle b = new Bundle();
        b.putString("query", query);
        getSupportLoaderManager().restartLoader(ANIMAL_LOADER, b, this);
    }
}

From source file:ch.ethz.twimight.activities.SearchableActivity.java

private void processIntent(Intent intent) {
    if (intent.hasExtra(SearchManager.QUERY)) {
        //if (!intent.getStringExtra(SearchManager.QUERY).equals(query))
        query = intent.getStringExtra(SearchManager.QUERY);
        setTitle(getString(R.string.results_for) + query);

        SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                TwimightSuggestionProvider.AUTHORITY, TwimightSuggestionProvider.MODE);
        suggestions.saveRecentQuery(query, null);

    }/*from   w  ww.  ja v  a  2 s.c  o  m*/
}

From source file:net.naonedbus.fragment.impl.SearchFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final ActionBar actionBar = ((SherlockFragmentActivity) getActivity()).getSupportActionBar();

    mModalSearchView = (ModalSearchView) actionBar.getCustomView();
    mModalSearchView.setOnQueryTextListener(this);
    mModalSearchView.requestFocus();/* w  ww. j a va 2 s .c o  m*/

    final Intent queryIntent = getActivity().getIntent();
    final String queryAction = queryIntent.getAction();
    if (Intent.ACTION_SEARCH.equals(queryAction)) {
        if (queryIntent.getData() == null) {
            // Lancer la recherche
            final String query = queryIntent.getStringExtra(SearchManager.QUERY);
            mModalSearchView.setText(query);
        } else {
            final Integer selectedItemId = Integer.valueOf(queryIntent.getStringExtra(SearchManager.QUERY));
            final int typeId = Integer.valueOf(queryIntent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
            final TypeOverlayItem selectedItemType = TypeOverlayItem.getById(typeId);

            if (selectedItemType.equals(TypeOverlayItem.TYPE_STATION)) {
                // Afficher les parcours de l'arrt slectionn
                final Intent intent = new Intent(getActivity(), ParcoursActivity.class);
                intent.putExtra(ParcoursActivity.PARAM_ID_SATION, selectedItemId);
                startActivity(intent);
            } else {
                // Afficher l'lment sur la carte
                final ParamIntent intent = new ParamIntent(getActivity(), MapActivity.class);
                intent.putExtra(MapFragment.PARAM_ITEM_ID, selectedItemId);
                intent.putExtra(MapFragment.PARAM_ITEM_TYPE, selectedItemType.getId());
                startActivity(intent);
            }
            getActivity().finish();
        }
    }

    mModalSearchView.requestFocus();
}

From source file:org.bwgz.quotation.activity.SearchResultsActivity.java

private void handleIntent(final Intent intent) {
    Log.d(TAG, String.format("handleIntent - intent: %s", intent));

    String query = intent.getStringExtra(SearchManager.QUERY);
    int type = intent.getIntExtra(SearchResultsActivity.EXTRA_SEARCH_TYPE, FreebaseSearch.SEARCH_TYPE_KEYWORD);

    getTracker().send(MapBuilder.createEvent("ui.search", getSearchType(type), query, null).build());

    searchResultsAdapter = new SearchResultsAdapter(this, R.layout.quotation_pick_view, new ArrayList<Pick>(),
            this, getImageLoader());
    loadSearchResultsTask = (SearchResultsTask) new SearchResultsTask(this, searchResultsAdapter, 0,
            DEFAULT_LIMIT).execute(intent);

    ListView listView = (ListView) findViewById(R.id.result_list);
    listView.setAdapter(searchResultsAdapter);

    listView.setOnScrollListener(new OnScrollListener() {
        @Override//from  w  w w .  j av  a  2 s.c om
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            Log.d(TAG, String.format(
                    "onScroll - view %s  firstVisibleItem: %d  visibleItemCount: %d  totalItemCount: %d", view,
                    firstVisibleItem, visibleItemCount, totalItemCount));
            if ((loadSearchResultsTask.getStatus() == AsyncTask.Status.FINISHED)
                    && (totalItemCount < searchResultsAdapter.getHits())
                    && (firstVisibleItem + visibleItemCount == totalItemCount)) {
                Log.d(TAG, "Load Next Page!");

                loadSearchResultsTask = (SearchResultsTask) new SearchResultsTask(SearchResultsActivity.this,
                        searchResultsAdapter, totalItemCount, Math.max(visibleItemCount, DEFAULT_LIMIT))
                                .execute(intent);
            }
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    });

    listView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SearchResultsAdapter adapter = (SearchResultsAdapter) parent.getAdapter();

            List<String> mids = new ArrayList<String>();
            for (int i = 0; i < adapter.getCount(); i++) {
                Pick pick = (Pick) adapter.getItem(i);
                mids.add(pick.getId());
            }

            Intent intent = new Intent(getApplicationContext(), QuotationActivity.class);
            intent.putExtra(QuotationActivity.EXTRA_IDS, mids.toArray(new String[mids.size()]));
            intent.putExtra(QuotationActivity.EXTRA_POSITION, position);
            startActivity(intent);
        }
    });

}

From source file:com.google.android.apps.iosched.ui.SearchActivity.java

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);//from   w ww  .  ja v  a  2s  . c o  m
    mQuery = intent.getStringExtra(SearchManager.QUERY);

    final CharSequence title = getString(R.string.title_search_query, mQuery);
    getActivityHelper().setActionBarTitle(title);

    mTabHost.setCurrentTab(0);

    mSessionsFragment.reloadFromArguments(getSessionsFragmentArguments());
    mVendorsFragment.reloadFromArguments(getVendorsFragmentArguments());
}

From source file:com.purdue.CampusFeed.Activities.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();/*w w  w.j  a v  a 2  s . com*/
    }
    super.onCreate(savedInstanceState);
    myEvent = (Event) getIntent().getParcelableExtra(getString(R.string.EVENT));
    // Set main content view. On smaller screen devices this is a single pane view with one
    // fragment. One larger screen devices this is a two pane view with two fragments.
    setContentView(R.layout.invite_activity_main);
    getActionBar().setHomeButtonEnabled(true);

    // Check if two pane bool is set based on resource directories
    isTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes);

    // Check if this activity instance has been triggered as a result of a search query. This
    // will only happen on pre-HC OS versions as from HC onward search is carried out using
    // an ActionBar SearchView which carries out the search in-line without loading a new
    // Activity.
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {

        // Fetch query from intent and notify the fragment that it should display search
        // results instead of all contacts.
        String searchQuery = getIntent().getStringExtra(SearchManager.QUERY);
        ContactsListFragment mContactsListFragment = (ContactsListFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contact_list);

        // This flag notes that the Activity is doing a search, and so the result will be
        // search results rather than all contacts. This prevents the Activity and Fragment
        // from trying to a search on search results.
        isSearchResultView = true;
        mContactsListFragment.setSearchQuery(searchQuery);

        // Set special title for search results
        String title = getString(R.string.contacts_list_search_results_title, searchQuery);
        setTitle(title);
    }

    if (isTwoPaneLayout) {
        // If two pane layout, locate the contact detail fragment
        mContactDetailFragment = (ContactDetailFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contact_detail);
    }
}

From source file:org.klnusbaum.udj.PlayerSelectorActivity.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, PlayerSelectorActivity.class);
        startActivityForResult(intent, 0);
    } else {/*from   w w  w. j  ava2  s  .com*/
        super.onNewIntent(intent);
    }
}

From source file:com.conferenceengineer.android.iosched.ui.SearchActivity.java

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);/*  www  .  j a v  a  2s  . c om*/
    String query = intent.getStringExtra(SearchManager.QUERY);

    setTitle(Html.fromHtml(getString(R.string.title_search_query, query)));

    mSessionsFragment.reloadFromArguments(
            intentToFragmentArguments(new Intent(Intent.ACTION_VIEW, Sessions.buildSearchUri(query))));

    LOGD("Tracker", "Search: " + query);

    updateDetailBackground();
}

From source file:org.tvheadend.tvhclient.SearchResultActivity.java

@Override
public void onCreate(Bundle icicle) {
    setTheme(Utils.getThemeId(this));
    super.onCreate(icicle);
    setContentView(R.layout.list_layout);

    // Setup the action bar and show the title
    actionBar = getSupportActionBar();//  w w w  .  j a va  2  s  .com
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setTitle(R.string.menu_search);
    actionBar.setSubtitle(getIntent().getStringExtra(SearchManager.QUERY));

    listView = (ListView) findViewById(R.id.item_list);
    registerForContextMenu(listView);

    List<Program> list = new ArrayList<Program>();
    adapter = new SearchResultAdapter(this, list);
    adapter.sort();
    listView.setAdapter(adapter);

    // Show the details of the program when the user has selected one
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            program = adapter.getItem(position);
            if (program != null) {
                Bundle args = new Bundle();
                args.putLong(Constants.BUNDLE_PROGRAM_ID, program.id);
                args.putLong(Constants.BUNDLE_CHANNEL_ID, program.channel.id);
                args.putBoolean(Constants.BUNDLE_DUAL_PANE, false);
                args.putBoolean(Constants.BUNDLE_SHOW_CONTROLS, true);
                // Create the fragment and show it as a dialog.
                DialogFragment newFragment = ProgramDetailsFragment.newInstance(args);
                newFragment.show(getSupportFragmentManager(), "dialog");
            }
        }
    });

    onNewIntent(getIntent());
}

From source file:com.owncloud.android.ui.activity.ShareActivity.java

@Override
protected void onNewIntent(Intent intent) {
    // Verify the action and get the query
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        Log_OC.w(TAG, "Ignored Intent requesting to query for " + query);

    } else if (UsersAndGroupsSearchProvider.ACTION_SHARE_WITH.equals(intent.getAction())) {
        Uri data = intent.getData();//from  www  .  j  av a 2 s  .  co  m
        doShareWith(data.getLastPathSegment(),
                UsersAndGroupsSearchProvider.DATA_GROUP.equals(data.getAuthority()));

    } else {
        Log_OC.wtf(TAG, "Unexpected intent " + intent.toString());
    }
}