2011-12-08 47 views
2

我正在嘗試爲qsb實施自定義建議。我已添加CREATE TABLE IF NOT EXISTS suggestion_table (_id INTEGER PRIMARY KEY AUTOINCREMENT, suggest_text_1 VARCHAR(50),suggest_intent_data INTEGER)作爲建議表。 intent.getDataString()的輸出僅爲content://com.simple.search.SuggestionProvider/tests。我真的很困惑。我認爲它會給出值suggest_intent_data。如何從intent獲得suggest_intent_data列的內容?快速搜索框:無法獲得SUGGEST_COLUMN_INTENT_DATA

if (Intent.ACTION_VIEW.equals(intent.getAction())) { 
    Log.d(Tag.getTag(this), (intent.getDataString())); 
    }; 

http://developer.android.com/guide/topics/search/adding-custom-suggestions.html

定義您的建議表的 SUGGEST_COLUMN_INTENT_DATA柱內的每個建議的數據。

通過包含SUGGEST_COLUMN_INTENT_DATA列 ,然後爲每行填充唯一數據,爲建議表中的每個意向提供所有必要的數據信息。 此列的數據與您在此 列中定義的意圖完全相同。然後,您可以使用getData()或getDataString()來檢索它。

searchable.xml

<?xml version="1.0" encoding="utf-8"?> 
<searchable xmlns:android="http://schemas.android.com/apk/res/android" 
    android:hint="@string/search_hint" 
    android:label="@string/app_label" 
    android:searchSuggestAuthority="com.simple.search.SuggestionProvider" 
    android:searchSuggestIntentAction="android.intent.action.VIEW" 
    android:searchSuggestIntentData="content://com.simple.search.SuggestionProvider/tests" //yeah, I thought this was causing the problem too. But after removing this line no change. 
    android:searchSuggestThreshold="1" 
    android:searchSuggestSelection=" ?" 
    /> 

回答

0

我是不是從表中選擇suggest_text_1suggest_intent_data在執行查詢。添加這些修復它。