谷歌Play商店中的应用程序最近查询

问题描述:

使用此代码,我能够清除在谷歌Play商店中的应用程序最近查询:谷歌Play商店中的应用程序最近查询

SearchRecentSuggestions query = new SearchRecentSuggestions(this, "com.google.android.finsky.RecentSuggestionsProvider", 1);  
query.clearHistory(); 

但是,我怎么能使用最新的查询? (例如:显示TextView中的第一个查询)

+0

如何修复SecurityException? java.lang.SecurityException:权限拒绝:打开提供程序com.google.android.finsky.providers.RecentSuggestionsProvider – Proverbio 2015-01-22 08:06:15

默认情况下,将查询作为uri参数(Uri对象)的最后一个段添加。要在这种情况下检索查询文本,只需使用getLastPathSegment()。例如:

String query = uri.getLastPathSegment()。toLowerCase();

例如,这里是你会如何形成的android:searchSuggestSelection属性来创建一个全文检索语句:

`

<?xml version="1.0" encoding="utf-8"?> 
<searchable xmlns:android="http://schemas.android.com/apk/res/android" 
    android:label="@string/app_label" 
    android:hint="@string/search_hint" 
    android:searchSuggestAuthority="com.example.MyCustomSuggestionProvider" 
    android:searchSuggestIntentAction="android.intent.action.VIEW" 
    android:searchSuggestSelection="word MATCH ?"> 
</searchable> 

` 有了这个配置,您的查询()方法提供选择参数为“词匹配?”和selectionArgs参数作为搜索查询。当你将这些传递给一个SQLite query()方法作为它们各自的参数时,它们被合成在一起(问号被替换为查询文本)。如果您选择以这种方式接收建议查询,并且需要向查询文本添加通配符,请将它们附加(和/或前缀)到selectionArgs参数,因为此值使用引号括起来并插入问号标记的位置。

上述示例中的另一个新属性是android:searchSuggestIntentAction,它定义了当用户选择建议时随每个意向发送的意向操作。有关声明建议意图的部分将对此进行进一步讨论。

+0

如何以这种方式访问​​查询? – monte 2013-03-19 06:57:34

+0

'//获取意图,//验证操作并获取查询Intent intent = getIntent(); (Intent.ACTION_SEARCH.equals(intent.getAction())){String query = intent.getStringExtra(SearchManager.QUERY); doMySearch(查询); }' – 2013-03-19 07:05:30

+0

我无法理解这个想法。我想要的不是清除查询,我怎样才能使用它的数据。就像列出它们或将它们放入textview中一样。 – monte 2013-03-19 09:00:33