【发布时间】:2017-11-22 17:31:07
【问题描述】:
我正在尝试在主屏幕上选择一个程序,但我不断收到提示“现在无法打开它”的提示。
这是我的清单以及我的节目是如何添加到 TV Provider 的。我将意图 uri、内部提供商 ID 和内容 ID 设置为彻底。
根据日志,我的接收器似乎从未启动过。
将节目添加到 TV Provider 的类:
private static final Uri BASE_URI = Uri.parse(SCHEME + "://" + APPS_LAUNCH_HOST);
public static final String START_APP_ACTION_PATH = "startapp";
public static final String PLAY_VIDEO_ACTION_PATH = "playvideo";
public void addProgram(Movie movie) {
...
PreviewProgram.Builder builder = new PreviewProgram.Builder()
.setChannelId(channelId)
.setTitle(movie.getTitle())
.setDescription(movie.getDescription())
.setDurationMillis(Long.valueOf(movie.getDuration()).intValue())
.setType(TvContractCompat.PreviewPrograms.TYPE_MOVIE)
.setIntentUri(Uri
.withAppendedPath(BASE_URI, PLAY_VIDEO_ACTION_PATH)
.buildUpon()
.appendPath(movieId)
.build())
.setInternalProviderId(movieId)
.setContentId(movieId)
...
}
public static long parseVideoId(Uri uri) {
List<String> segments = uri.getPathSegments();
if( segments.size() == 2 && PLAY_VIDEO_ACTION_PATH.equals(segments.get(0)) ) {
return Long.valueOf(segments.get(1));
}
return -1L;
}
Android 清单
<receiver android:name=".PlayVideoReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="<scheme>"
android:host="<host>"
android:path="/playvideo" />
</intent-filter>
</receiver>
【问题讨论】:
标签: android-tv