MichaelMelaku

Using SearchView to search from Multiple feature classes in a map service

Discussion created by MichaelMelaku on Aug 26, 2013
Hello Everyone,

I am developing an Android app, quite novice but i managed so far. I am now hanging on how to use the Searchview to enable users type any landmark they are aware of. Meanwhile, i want to show the possible place names as they type along. I want to query from the selected feature classes in a map service. I have used the sample implementation online but no luck on getting a resource how to deal with map services and layers.

Here is the searching function i got online but i really don't know how to set it up for layers.

private void setupSearchView(MenuItem searchItem) {

        if (isAlwaysExpanded()) {
            mSearchView.setIconifiedByDefault(false);
        } else {
            searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM
                    | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
        }

        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        if (searchManager != null) {
            List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();

            SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
            for (SearchableInfo inf : searchables) {
                if (inf.getSuggestAuthority() != null
                        && inf.getSuggestAuthority().startsWith("applications")) {
                    info = inf;
                }
            }
            mSearchView.setSearchableInfo(info);
        }

        mSearchView.setOnQueryTextListener(this);
    }

Screaming for help.

Outcomes