Example usage for android.app SearchManager APP_DATA

List of usage examples for android.app SearchManager APP_DATA

Introduction

In this page you can find the example usage for android.app SearchManager APP_DATA.

Prototype

String APP_DATA

To view the source code for android.app SearchManager APP_DATA.

Click Source Link

Document

Intent extra data key: Use this key with Intent.ACTION_SEARCH and android.content.Intent#getBundleExtra content.Intent.getBundleExtra() to obtain any additional app-specific data that was inserted by the activity that launched the search.

Usage

From source file:net.potterpcs.recipebook.RecipeBookActivity.java

private void handleIntent(Intent intent) {
    // Fill in all the search/sort criteria
    if (intent.hasExtra(RecipeBook.SEARCH_EXTRA)) {
        searchQuery = intent.getStringExtra(RecipeBook.SEARCH_EXTRA);
    } else {//from w  w  w  .  ja va 2s  .  c om
        searchQuery = intent.getStringExtra(SearchManager.QUERY);
    }

    searchMode = (searchQuery != null);

    Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA);
    if (searchData == null) {
        sortDescending = intent.getBooleanExtra(SORT_DESCENDING, false);
        sortKey = intent.getIntExtra(SORT_KEY, 0);
        tagSearchMode = intent.hasExtra(RecipeBook.TAG_EXTRA);
        searchTag = intent.getStringExtra(RecipeBook.TAG_EXTRA);
        searchMin = intent.getIntExtra(RecipeBook.TIME_EXTRA_MIN, 0);
        searchMax = intent.getIntExtra(RecipeBook.TIME_EXTRA_MAX, 0);
        timeSearchMode = (searchMin != 0 || searchMax != 0);
    } else {
        sortDescending = searchData.getBoolean(SORT_DESCENDING, false);
        sortKey = searchData.getInt(SORT_KEY, 0);
        tagSearchMode = searchData.containsKey(RecipeBook.TAG_EXTRA);
        searchTag = searchData.getString(RecipeBook.TAG_EXTRA);
        searchMin = searchData.getInt(RecipeBook.TIME_EXTRA_MIN, 0);
        searchMax = searchData.getInt(RecipeBook.TIME_EXTRA_MAX, 0);
        timeSearchMode = (searchMin != 0 || searchMax != 0);
    }

    // In case the max value is left blank
    if (searchMax == 0 && searchMin > 0) {
        searchMax = Integer.MAX_VALUE;
    }

    //      Log.i(TAG, "Sort descending == " + sortDescending + ", sort key == " + sortKey 
    //            + " max time == " + searchMax + " min time == " + searchMin);

    // Android 3.0+ has the action bar, and requires this call to change menu items.
    // Earlier versions don't have it, because they don't need it.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        invalidateOptionsMenu();
    }
}

From source file:com.deliciousdroid.activity.BrowseBookmarks.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browse_bookmarks);

    Intent intent = getIntent();//from w  w w  .  ja va  2s  . c  om

    Uri data = intent.getData();
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction t = fm.beginTransaction();

    Fragment bookmarkFrag;

    if (fm.findFragmentById(R.id.listcontent) == null) {
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA);

            if (searchData != null) {
                tagname = searchData.getString("tagname");
                username = searchData.getString("username");
                unread = searchData.getBoolean("unread");
            }

            query = intent.getStringExtra(SearchManager.QUERY);

            if (intent.hasExtra("username")) {
                username = intent.getStringExtra("username");
            }

            if (data != null && data.getUserInfo() != null) {
                username = data.getUserInfo();
            }
        } else {
            if (data != null) {
                if (data.getUserInfo() != "") {
                    username = data.getUserInfo();
                } else
                    username = mAccount.name;
                tagname = data.getQueryParameter("tagname");
                unread = data.getQueryParameter("unread") != null;
                path = data.getPath();
            }
        }

        if (isMyself()) {
            bookmarkFrag = new BrowseBookmarksFragment();
        } else {
            bookmarkFrag = new BrowseBookmarkFeedFragment();
        }

        t.add(R.id.listcontent, bookmarkFrag);
    } else {
        if (savedInstanceState != null) {
            username = savedInstanceState.getString(STATE_USERNAME);
            tagname = savedInstanceState.getString(STATE_TAGNAME);
            unread = savedInstanceState.getBoolean(STATE_UNREAD);
            query = savedInstanceState.getString(STATE_QUERY);
            path = savedInstanceState.getString(STATE_PATH);
        }

        bookmarkFrag = fm.findFragmentById(R.id.listcontent);
    }

    if (isMyself()) {
        if (query != null && !query.equals("")) {
            ((BrowseBookmarksFragment) bookmarkFrag).setSearchQuery(query, username, tagname, unread);
        } else {
            ((BrowseBookmarksFragment) bookmarkFrag).setQuery(username, tagname, unread);
        }
    } else {
        if (query != null && !query.equals("")) {
            ((BrowseBookmarkFeedFragment) bookmarkFrag).setQuery(username, tagname);
        } else {
            ((BrowseBookmarkFeedFragment) bookmarkFrag).setQuery(username, query);
        }
    }

    BrowseTagsFragment tagFrag = (BrowseTagsFragment) fm.findFragmentById(R.id.tagcontent);
    if (tagFrag != null) {
        tagFrag.setAccount(username);
    }

    if (path != null && path.contains("tags")) {
        t.hide(fm.findFragmentById(R.id.maincontent));
        findViewById(R.id.panel_collapse_button).setVisibility(View.GONE);
    } else {
        if (tagFrag != null) {
            t.hide(tagFrag);
        }
    }

    Fragment addFrag = fm.findFragmentById(R.id.addcontent);
    if (addFrag != null) {
        t.hide(addFrag);
    }

    t.commit();
}

From source file:org.barbon.mangaget.fragments.MangaSearchResults.java

public void performSearch(Intent intent) {
    Scraper scraper = Scraper.getInstance(getActivity());
    String query = intent.getStringExtra(SearchManager.QUERY);
    Bundle extra = intent.getBundleExtra(SearchManager.APP_DATA);
    Scraper.SearchCriteria criteria = new Scraper.SearchCriteria();

    criteria.title = query;/*from   w  w w. j  a  v  a2  s.  co m*/
    if (extra != null)
        criteria.includeTags = extra.getStringArrayList("include_tags");

    setListAdapter(new SearchAdapter(getActivity(), scraper, criteria));
}

From source file:com.pindroid.activity.BrowseBookmarks.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browse_bookmarks);

    Intent intent = getIntent();// ww w  .  j ava2  s.com

    Uri data = intent.getData();
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction t = fm.beginTransaction();

    if (fm.findFragmentById(R.id.listcontent) == null) {
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA);

            if (searchData != null) {
                tagname = searchData.getString("tagname");
                app.setUsername(searchData.getString("username"));
                unread = searchData.getBoolean("unread");
            }

            query = intent.getStringExtra(SearchManager.QUERY);

            if (intent.hasExtra("username")) {
                app.setUsername(intent.getStringExtra("username"));
            }

            if (data != null) {
                feed = data.getQueryParameter("feed");

                if (data.getUserInfo() != null) {
                    app.setUsername(data.getUserInfo());
                }
            }
        } else {
            if (data != null) {
                tagname = data.getQueryParameter("tagname");
                feed = data.getQueryParameter("feed");
                unread = data.getQueryParameter("unread") != null;
                path = data.getPath();
            }
        }

        if (feed == null || feed.equals("")) {
            bookmarkFrag = new BrowseBookmarksFragment();
        } else {
            bookmarkFrag = new BrowseBookmarkFeedFragment();
        }

        t.add(R.id.listcontent, bookmarkFrag);
    } else {
        if (savedInstanceState != null) {
            tagname = savedInstanceState.getString(STATE_TAGNAME);
            unread = savedInstanceState.getBoolean(STATE_UNREAD);
            query = savedInstanceState.getString(STATE_QUERY);
            path = savedInstanceState.getString(STATE_PATH);
            feed = savedInstanceState.getString(STATE_FEED);
        }

        bookmarkFrag = fm.findFragmentById(R.id.listcontent);
    }

    if (feed == null || feed.equals("")) {
        if (query != null && !query.equals("")) {
            ((BrowseBookmarksFragment) bookmarkFrag).setSearchQuery(query, app.getUsername(), tagname, unread);
        } else {
            ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), tagname, unread ? "unread" : null);
        }

        ((BrowseBookmarksFragment) bookmarkFrag).refresh();
    } else {
        if (query == null || query.equals("")) {
            ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), tagname, feed);
        } else {
            ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), query, feed);
        }
    }

    BrowseTagsFragment tagFrag = (BrowseTagsFragment) fm.findFragmentById(R.id.tagcontent);

    if (tagFrag != null) {
        tagFrag.setAccount(app.getUsername());
    }

    if (path != null && path.contains("tags")) {
        t.hide(fm.findFragmentById(R.id.maincontent));
        findViewById(R.id.panel_collapse_button).setVisibility(View.GONE);
    } else {
        if (tagFrag != null) {
            t.hide(tagFrag);
        }
    }

    Fragment addFrag = fm.findFragmentById(R.id.addcontent);
    if (addFrag != null) {
        t.hide(addFrag);
    }

    t.commit();
}

From source file:com.android.stockbrowser.search.OpenSearchSearchEngine.java

public void startSearch(Context context, String query, Bundle appData, String extraData) {
    String uri = mSearchEngineInfo.getSearchUriForQuery(query);
    if (uri == null) {
        Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo);
    } else {//from w ww  .  j  a v a2s . c om
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        // Make sure the intent goes to the StockBrowser itself
        intent.setPackage(context.getPackageName());
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(SearchManager.QUERY, query);
        if (appData != null) {
            intent.putExtra(SearchManager.APP_DATA, appData);
        }
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(intent);
    }
}

From source file:com.android.browser.search.OpenSearchSearchEngine.java

public void startSearch(Context context, String query, Bundle appData, String extraData) {
    String uri = mSearchEngineInfo.getSearchUriForQuery(query);
    if (uri == null) {
        Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo);
    } else {// w  w w.  j a  va  2  s . c o m
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        // Make sure the intent goes to the Browser itself
        intent.setPackage(context.getPackageName());
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(SearchManager.QUERY, query);
        if (appData != null) {
            intent.putExtra(SearchManager.APP_DATA, appData);
        }
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(intent);
    }
}

From source file:com.kyakujin.android.tagnotepad.ui.NoteActivity.java

/**
 * ?/*from   www  .  j  a  v  a  2  s . c  o  m*/
 *
 * @param intent the intent
 */
private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        String tagname = null;
        final Bundle bundle = intent.getBundleExtra(SearchManager.APP_DATA);
        if (bundle != null) {
            // ????????????????
            // ??"Tag_A"????????????
            // ???????
            // "Tag_A"?where????
            tagname = bundle.getString(Config.SELECTED_TAGNAME);
        }

        doSearch(query, tagname);
    }
}

From source file:com.borqs.browser.search.OpenSearchSearchEngine.java

public void startSearch(Context context, String query, Bundle appData, String extraData) {
    Log.i("OpenSearchSearchEng", "startSearch, query: " + query);
    String uri = mSearchEngineInfo.getSearchUriForQuery(query);
    if (uri == null) {
        Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo);
    } else {//from ww w . j a v  a2s  . c o  m
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        // Make sure the intent goes to the Browser itself
        intent.setPackage(context.getPackageName());
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(SearchManager.QUERY, query);
        if (appData != null) {
            intent.putExtra(SearchManager.APP_DATA, appData);
        }
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(intent);
    }
}

From source file:com.example.domiter.fileexplorer.fragment.SearchListFragment.java

private void handleIntent() {
    Intent intent = getActivity().getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // Get the query.
        mQuery = intent.getStringExtra(SearchManager.QUERY);
        getActivity().getActionBar().setTitle(mQuery);

        // Get the current path
        String path = intent.getBundleExtra(SearchManager.APP_DATA)
                .getString(IntentConstants.EXTRA_SEARCH_INIT_PATH);
        mRoot = new File(path);
        getActivity().getActionBar().setSubtitle(path);

        // Start the actual search
        getLoaderManager().initLoader(LOADER_ID, null, this);
        getActivity().setProgressBarIndeterminateVisibility(true);
    }// w  w w.  j a  v  a 2s .c om
    // We're here because of a clicked suggestion
    else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        browse(intent.getData());

        getActivity().finish();
    } else {
        // Intent contents error.
        getActivity().setTitle(R.string.query_error);
        setLoading(false);
    }
}

From source file:com.battlelancer.seriesguide.ui.SearchActivity.java

private void handleIntent(Intent intent) {
    if (intent == null) {
        return;/*  www. j av  a2 s.  c  o m*/
    }
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        Bundle extras = getIntent().getExtras();

        // searching episodes within a show?
        Bundle appData = extras.getBundle(SearchManager.APP_DATA);
        if (appData != null) {
            String showTitle = appData.getString(EpisodeSearchFragment.InitBundle.SHOW_TITLE);
            if (!TextUtils.isEmpty(showTitle)) {
                // change title + switch to episodes tab if show restriction was submitted
                viewPager.setCurrentItem(EPISODES_TAB_INDEX);
            }
        }

        // setting the query automatically triggers a search
        String query = extras.getString(SearchManager.QUERY);
        searchBar.setText(query);
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri data = intent.getData();
        String id = data.getLastPathSegment();
        displayEpisode(id);
        Utils.trackCustomEvent(this, TAG, "Search action", "View");
        finish();
    }
}