Example usage for android.content Context SEARCH_SERVICE

List of usage examples for android.content Context SEARCH_SERVICE

Introduction

In this page you can find the example usage for android.content Context SEARCH_SERVICE.

Prototype

String SEARCH_SERVICE

To view the source code for android.content Context SEARCH_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.app.SearchManager for handling searches.

Usage

From source file:com.owncloud.android.ui.fragment.FileDetailSharingFragment.java

private void setupView() {
    setShareByLinkInfo(file.isSharedViaLink());
    setShareWithUserInfo();/*from   w w  w  .j a va 2s.  c  o  m*/
    FileDetailSharingFragmentHelper.setupSearchView(
            (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE), searchView,
            getActivity().getComponentName());
}

From source file:cl.mmoscoso.geocomm.GeoCommMainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.map_view_main, menu);
    //SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    //menu.findItem(R.id.action_search).getActionView();
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    searchView.setOnQueryTextListener(this);
    return true;/*  www  .  ja v  a  2 s .  c  om*/
}

From source file:com.nick.scalpel.core.AutoFoundWirer.java

private void wireFromContext(Context context, AutoFound.Type type, int idRes, Resources.Theme theme,
        Field field, Object forWho) {
    Resources resources = context.getResources();
    switch (type) {
    case STRING:/*  w w  w . jav  a 2s  . c  o m*/
        setField(field, forWho, resources.getString(idRes));
        break;
    case COLOR:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            setField(field, forWho, resources.getColor(idRes, theme));
        } else {
            //noinspection deprecation
            setField(field, forWho, resources.getColor(idRes));
        }
        break;
    case INTEGER:
        setField(field, forWho, resources.getInteger(idRes));
        break;
    case BOOL:
        setField(field, forWho, resources.getBoolean(idRes));
        break;
    case STRING_ARRAY:
        setField(field, forWho, resources.getStringArray(idRes));
        break;
    case INT_ARRAY:
        setField(field, forWho, resources.getIntArray(idRes));
        break;
    case PM:
        setField(field, forWho, context.getSystemService(Context.POWER_SERVICE));
        break;
    case ACCOUNT:
        setField(field, forWho, context.getSystemService(Context.ACCOUNT_SERVICE));
        break;
    case ALARM:
        setField(field, forWho, context.getSystemService(Context.ALARM_SERVICE));
        break;
    case AM:
        setField(field, forWho, context.getSystemService(Context.ACTIVITY_SERVICE));
        break;
    case WM:
        setField(field, forWho, context.getSystemService(Context.WINDOW_SERVICE));
        break;
    case NM:
        setField(field, forWho, context.getSystemService(Context.NOTIFICATION_SERVICE));
        break;
    case TM:
        setField(field, forWho, context.getSystemService(Context.TELEPHONY_SERVICE));
        break;
    case TCM:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setField(field, forWho, context.getSystemService(Context.TELECOM_SERVICE));
        }
        break;
    case SP:
        setField(field, forWho, PreferenceManager.getDefaultSharedPreferences(context));
        break;
    case PKM:
        setField(field, forWho, context.getPackageManager());
        break;
    case HANDLE:
        setField(field, forWho, new Handler(Looper.getMainLooper()));
        break;
    case ASM:
        setField(field, forWho, context.getSystemService(Context.ACCESSIBILITY_SERVICE));
        break;
    case CAP:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setField(field, forWho, context.getSystemService(Context.CAPTIONING_SERVICE));
        }
        break;
    case KGD:
        setField(field, forWho, context.getSystemService(Context.KEYGUARD_SERVICE));
        break;
    case LOCATION:
        setField(field, forWho, context.getSystemService(Context.LOCATION_SERVICE));
        break;
    case SEARCH:
        setField(field, forWho, context.getSystemService(Context.SEARCH_SERVICE));
        break;
    case SENSOR:
        setField(field, forWho, context.getSystemService(Context.SENSOR_SERVICE));
        break;
    case STORAGE:
        setField(field, forWho, context.getSystemService(Context.STORAGE_SERVICE));
        break;
    case WALLPAPER:
        setField(field, forWho, context.getSystemService(Context.WALLPAPER_SERVICE));
        break;
    case VIBRATOR:
        setField(field, forWho, context.getSystemService(Context.VIBRATOR_SERVICE));
        break;
    case CONNECT:
        setField(field, forWho, context.getSystemService(Context.CONNECTIVITY_SERVICE));
        break;
    case NETWORK_STATUS:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            setField(field, forWho, context.getSystemService(Context.NETWORK_STATS_SERVICE));
        }
        break;
    case WIFI:
        setField(field, forWho, context.getSystemService(Context.WIFI_SERVICE));
        break;
    case AUDIO:
        setField(field, forWho, context.getSystemService(Context.AUDIO_SERVICE));
        break;
    case FP:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            setField(field, forWho, context.getSystemService(Context.FINGERPRINT_SERVICE));
        }
        break;
    case MEDIA_ROUTER:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setField(field, forWho, context.getSystemService(Context.MEDIA_ROUTER_SERVICE));
        }
        break;
    case SUB:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
            setField(field, forWho, context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE));
        }
        break;
    case IME:
        setField(field, forWho, context.getSystemService(Context.INPUT_METHOD_SERVICE));
        break;
    case CLIP_BOARD:
        setField(field, forWho, context.getSystemService(Context.CLIPBOARD_SERVICE));
        break;
    case APP_WIDGET:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setField(field, forWho, context.getSystemService(Context.APPWIDGET_SERVICE));
        }
        break;
    case DEVICE_POLICY:
        setField(field, forWho, context.getSystemService(Context.DEVICE_POLICY_SERVICE));
        break;
    case DOWNLOAD:
        setField(field, forWho, context.getSystemService(Context.DOWNLOAD_SERVICE));
        break;
    case BATTERY:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setField(field, forWho, context.getSystemService(Context.BATTERY_SERVICE));
        }
        break;
    case NFC:
        setField(field, forWho, context.getSystemService(Context.NFC_SERVICE));
        break;
    case DISPLAY:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            setField(field, forWho, context.getSystemService(Context.DISPLAY_SERVICE));
        }
        break;
    case USER:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            setField(field, forWho, context.getSystemService(Context.USER_SERVICE));
        }
        break;
    case APP_OPS:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setField(field, forWho, context.getSystemService(Context.APP_OPS_SERVICE));
        }
        break;
    case BITMAP:
        setField(field, forWho, BitmapFactory.decodeResource(resources, idRes, null));
        break;
    }
}

From source file:com.zns.comicdroid.activity.Start.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.actionbar_start, (com.actionbarsherlock.view.Menu) menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    mSearchView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mSearchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
        @Override// w w  w . j av  a2 s  .  c om
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                String query = mSearchView.getQuery().toString();
                if (query.trim().length() == 0) {
                    mMenuSearch.collapseActionView();
                    BaseListFragment fragment = getCurrentFragment();
                    if (fragment != null) {
                        fragment.clearFilter();
                    }
                }
            }
        }
    });

    return true;
}

From source file:sk.mpage.androidsample.searchviewtoolbar.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    return true;/*  w  w  w.ja v  a2  s .c om*/
}

From source file:br.com.moviecreator.views.home.HomeFragment.java

private void initSearch(MenuItem item) {
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);

    SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));

    if (criteria != null) {
        searchView.setIconified(false);/*from  w  ww  . j av  a  2s.com*/
    }

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            if (!query.equals(criteria) && query.length() > 2) {
                adapter.clear();
                searchMovie(query);
                criteria = query;
            }

            return false;
        }

        @Override
        public boolean onQueryTextChange(final String query) {
            if (query.equals(criteria) || query.length() < 3) {
                return true;
            }
            return false;
        }
    });
    searchView.setOnCloseListener(new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            /*adapter.clear();
                    
            fetch(null, null);*/

            return false;
        }
    });
}

From source file:asu.edu.msse.gpeddabu.moviedescriptions.AddMovie.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.movie_search_menu, menu);
    // setup the search in action bar
    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = (android.widget.SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(this);
    return true;/* w  ww  . j  a v a  2s  .com*/
}

From source file:info.guardianproject.otr.app.im.app.ContactsPickerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.contact_list_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));

    if (mSearchView != null) {
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        mSearchView.setIconifiedByDefault(false);

        SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
            public boolean onQueryTextChange(String newText) {
                mSearchString = newText;
                doFilterAsync(mSearchString);
                return true;
            }//from w ww  . j  av  a2s.  c  o  m

            public boolean onQueryTextSubmit(String query) {
                mSearchString = query;
                doFilterAsync(mSearchString);

                return true;
            }
        };

        mSearchView.setOnQueryTextListener(queryTextListener);
    }

    return true;
}

From source file:no.group09.ucsoftwarestore.MainActivity.java

/**
 * Creates options menu//ww w .  ja  va  2  s .  co  m
 */
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main_menu, menu);

    //When the menu is created, check the preferences and set the correct text
    if (sharedPref.getBoolean("hide_incompatible", false)) {
        menu.getItem(1).setTitle("Hide incompatible");
        menu.getItem(1).setChecked(true);

    } else {
        menu.getItem(1).setTitle("Hide incompatible");
        menu.getItem(1).setChecked(false);
    }

    //Search bar for versions over API level 11
    int SDK_INT = android.os.Build.VERSION.SDK_INT;

    if (SDK_INT >= 11) {
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();

        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setSubmitButtonEnabled(true);
    }
    return true;
}

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_app, menu);

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.product_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override//from   ww  w.  j  a v  a2 s  .c  o  m
        public boolean onQueryTextSubmit(String query) {
            m_ListFragment.setSearch((query));
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            m_ListFragment.setSearch((newText));
            return true;
        }
    });

    return super.onCreateOptionsMenu(menu);
}