Search in sources :

Example 16 with SearchManager

use of android.app.SearchManager in project PocketHub by pockethub.

the class IssueSearchActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu options) {
    getMenuInflater().inflate(R.menu.activity_search, options);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = options.findItem(R.id.m_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    Bundle args = new Bundle();
    args.putParcelable(EXTRA_REPOSITORY, repository);
    searchView.setAppSearchData(args);
    return true;
}
Also used : SearchManager(android.app.SearchManager) Bundle(android.os.Bundle) MenuItem(android.view.MenuItem)

Example 17 with SearchManager

use of android.app.SearchManager in project weiciyuan by qii.

the class AtUserFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.actionbar_menu_atuserfragment, menu);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setIconifiedByDefault(false);
    searchView.setQueryHint(getString(R.string.at_other));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (!TextUtils.isEmpty(newText)) {
                if (task != null) {
                    task.cancel(true);
                }
                task = new AtUserTask(newText);
                task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
            } else {
                if (task != null) {
                    task.cancel(true);
                }
                atList.clear();
                result.clear();
                atList = AtUsersDBTask.get(GlobalContext.getInstance().getCurrentAccountId());
                for (AtUserBean b : atList) {
                    result.add(b.getNickname());
                }
                adapter.notifyDataSetChanged();
            }
            return false;
        }
    });
    searchView.requestFocus();
}
Also used : SearchView(android.widget.SearchView) SearchManager(android.app.SearchManager) AtUserBean(org.qii.weiciyuan.bean.AtUserBean)

Example 18 with SearchManager

use of android.app.SearchManager in project weiciyuan by qii.

the class SearchMainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.actionbar_menu_searchmainactivity, menu);
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    searchView.setIconifiedByDefault(false);
    searchView.setSubmitButtonEnabled(false);
    searchView.requestFocus();
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.widget.SearchView) SearchManager(android.app.SearchManager)

Example 19 with SearchManager

use of android.app.SearchManager in project platform_frameworks_base by android.

the class SearchManagerTest method testSearchManagerInvocations.

/**
     * The goal of this test is to confirm that we can start and then
     * stop a simple search.
     */
public void testSearchManagerInvocations() throws Exception {
    SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    assertNotNull(searchManager);
    // These tests should simply run to completion w/o exceptions
    searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
    searchManager.stopSearch();
    searchManager.startSearch("", false, SEARCHABLE_ACTIVITY, null, false);
    searchManager.stopSearch();
    searchManager.startSearch("test search string", false, SEARCHABLE_ACTIVITY, null, false);
    searchManager.stopSearch();
    searchManager.startSearch("test search string", true, SEARCHABLE_ACTIVITY, null, false);
    searchManager.stopSearch();
}
Also used : ISearchManager(android.app.ISearchManager) SearchManager(android.app.SearchManager)

Example 20 with SearchManager

use of android.app.SearchManager in project platform_frameworks_base by android.

the class SearchManagerTest method testSearchManagerAvailable.

/**
     * The goal of this test is to confirm that we can obtain
     * a search manager at any time, and that for any given context,
     * it is a singleton.
     */
@LargeTest
public void testSearchManagerAvailable() {
    SearchManager searchManager1 = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    assertNotNull(searchManager1);
    SearchManager searchManager2 = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    assertNotNull(searchManager2);
    assertSame(searchManager1, searchManager2);
}
Also used : ISearchManager(android.app.ISearchManager) SearchManager(android.app.SearchManager) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

SearchManager (android.app.SearchManager)99 Intent (android.content.Intent)31 ISearchManager (android.app.ISearchManager)26 ActivityNotFoundException (android.content.ActivityNotFoundException)20 ComponentName (android.content.ComponentName)20 Bundle (android.os.Bundle)14 RecognizerIntent (android.speech.RecognizerIntent)12 SearchView (android.support.v7.widget.SearchView)12 MenuItem (android.view.MenuItem)12 UserHandle (android.os.UserHandle)10 View (android.view.View)9 ImageView (android.widget.ImageView)8 SearchView (android.widget.SearchView)8 TextView (android.widget.TextView)8 ActivityOptions (android.app.ActivityOptions)7 LargeTest (android.test.suitebuilder.annotation.LargeTest)6 AppWidgetHostView (android.appwidget.AppWidgetHostView)5 PackageManager (android.content.pm.PackageManager)5 ResolveInfo (android.content.pm.ResolveInfo)5 MenuInflater (android.view.MenuInflater)5