从ContentProvider的访问appSearchData包 [英] Accessing appSearchData bundle from ContentProvider

查看:124
本文介绍了从ContentProvider的访问appSearchData包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个活动被认为是能够提供上下文信息到这样一个内容提供商

An activity is supposed to be able to provide context information to a content provider like this:

@Override
public boolean onSearchRequested() {
    Bundle appSearchData = new Bundle();
    appSearchData.putByte("category", category);
    startSearch(null, false, appSearchData, false);
    return true;
}

从提供商的搜索建议和结果应仅限于'分类',但我找不到在哪里从我的ContentProvider访问appSearchData包。

Search suggestions and results from the provider should be limited to 'category', but I can't find where to access the appSearchData bundle from my ContentProvider.

推荐答案

使用此为onSearchRequested:

Use this for onSearchRequested:

@Override
public boolean onSearchRequested() {
    SearchManager searchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);

    if(searchManager!=null)
    {
        // start the search with the appropriate searchable activity
        // so we get the correct search hint in the search dialog
            Bundle b = new Bundle();
            b.putString("context", indicator);
            searchManager.startSearch(null, false,new ComponentName(this, YourClass.class), b, false);
    return true;
}
return false;
}

这是你的搜索类:

And this is your searchable class:

Bundle b = intent.getBundleExtra(SearchManager.APP_DATA);

这篇关于从ContentProvider的访问appSearchData包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆