Android电视全球搜索显示应用程序';使用不同的参数生成内容结果
所以我把我的应用程序连接到了全球搜索,一切都很好 我的问题是,在某些设备中,全局搜索结果的卡片视图的高度和宽度不同,并且看起来更像矩形而不是方形,这与大多数设备中导致图像无法完全显示的原因类似 我尝试了不同的方法来处理结果参数,但没有成功 对于youtube等其他应用程序,它在这两种情况下都运行良好 **这两种情况都发生在两款具有相同android版本、内核版本等的小米3拖缆上 更新 在检查了4台不同的设备后,我发现Android TV核心服务系统应用程序和Android TV家庭系统应用程序的版本在这两种情况下有所不同 在版本f-1.12中,它在正方形中工作良好,而在版本f-1.6中,视图为矩形 这有关系吗?如果是的话,那么如何解决这一问题,使双方都能工作 有没有办法管理显示的参数 方形图像- 矩形图像- 我对任何寻求者的实施- 清单声明(搜索意图活动和内容提供者)—— 可搜索xml-Android电视全球搜索显示应用程序';使用不同的参数生成内容结果,android,android-tv,Android,Android Tv,所以我把我的应用程序连接到了全球搜索,一切都很好 我的问题是,在某些设备中,全局搜索结果的卡片视图的高度和宽度不同,并且看起来更像矩形而不是方形,这与大多数设备中导致图像无法完全显示的原因类似 我尝试了不同的方法来处理结果参数,但没有成功 对于youtube等其他应用程序,它在这两种情况下都运行良好 **这两种情况都发生在两款具有相同android版本、内核版本等的小米3拖缆上 更新 在检查了4台不同的设备后,我发现Android TV核心服务系统应用程序和Android TV家庭系统应用程序的
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:hint="@string/search_hint"
android:searchSettingsDescription="@string/search_label"
android:searchSuggestAuthority="com.your.package.provider"
android:searchSuggestIntentAction="android.intent.action.VIEW"
android:searchSuggestIntentData="content://com.your.package.provider/search_suggest_query"
android:searchSuggestSelection="MATCH ?"
android:searchSuggestThreshold="1"
android:includeInGlobalSearch="true">
</searchable>
我非常感谢在这个问题上有任何线索
public class AppContentProvider extends ContentProvider {
private static final String AUTHORITY = "com.your.package.provider";
@Override
public boolean onCreate() {
return true;
}
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, String[] selectionArgs, @Nullable String sortOrder) {
if (selectionArgs == null) {
throw new IllegalArgumentException(
"selectionArgs must be provided for the Uri: " + uri);
}
//... do API calls if required...
return getSuggestions(selectionArgs[0]);
}
private Cursor getSuggestions(String query) {
query = query.toLowerCase();
String[] columns = new String[]{
KEY_ID,
KEY_NAME,
KEY_DESCRIPTION,
KEY_IMAGE,
KEY_DATA,
};
return getWordMatch(query, columns);
}
private Cursor getWordMatch(String query, String[] columns) {
// implemented with MatrixCursor because I first fetch from api and than build the row instead of fetching a Curser directly from DB
MatrixCursor matrixCursor = new MatrixCursor(columns, columns.length);
//... some data building code ...
String[] searchResultMap = new String[]{
String.valueOf(searchResult.getVodId()),
searchResult.getTitle(),
searchResult.getDescription(),
url,
assetToSend.toString() // Here send a Json of the search result object to fetch at SearchSuggestionActivity (this is basically SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA's column)
};
matrixCursor.addRow(searchResultMap);
return matrixCursor;
}
public class SearchContentTableConsts {
//The columns we'll include in the video database table
static final String KEY_ID = BaseColumns._ID;
static final String KEY_NAME = SearchManager.SUGGEST_COLUMN_TEXT_1;
static final String KEY_DESCRIPTION = SearchManager.SUGGEST_COLUMN_TEXT_2;
static final String KEY_IMAGE = SearchManager.SUGGEST_COLUMN_RESULT_CARD_IMAGE;
static final String KEY_DATA = SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA;
}
}
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:hint="@string/search_hint"
android:searchSettingsDescription="@string/search_label"
android:searchSuggestAuthority="com.your.package.provider"
android:searchSuggestIntentAction="android.intent.action.VIEW"
android:searchSuggestIntentData="content://com.your.package.provider/search_suggest_query"
android:searchSuggestSelection="MATCH ?"
android:searchSuggestThreshold="1"
android:includeInGlobalSearch="true">
</searchable>
public class SearchSuggestionActivity extends AppCompatActivity {
String TAG = SearchSuggestionActivity.class.getSimpleName();
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent().getExtras() == null) {
finish();
}
catchSearchAssetInfo();
}
private void catchSearchAssetInfo() {
String searchResultJson = getIntent().getExtras().getString(SearchManager.EXTRA_DATA_KEY);
JSONObject jsonObject;
try {
jsonObject = new JSONObject(searchResultJson);
// Create your data from the jsonObject
} catch (JSONException err) {
Log.d(TAG, "Error - " + err.toString());
}
proceedToAsset();
}
private void proceedToAsset() {
// Open result page for example
}
}