2017-11-22 15 views
0

홈 화면에서 프로그램을 선택하려고하는데 '지금 열 수 없습니다'라는 메시지가 계속 표시됩니다.Android TV의 홈 화면에서 프로그램을 시작할 수 없습니다.

다음은 내 매니페스트이며 TV 프로그램에 내 프로그램이 추가되는 방식입니다. 의도 uri, 내부 공급자 ID 및 콘텐츠 ID를 철저히 설정합니다.

로그를 기반으로하면 내 수신자가 실행되지 않는 것처럼 보입니다. 텔레비전 제공자에 프로그램을 추가

등급 :

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; 
} 

안드로이드 매니페스트

<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> 

답변

0

내 매니페스트 문제의 부부가 있었다. URI가 끝나는 때문에

scheme://host/playvideo/<id>되는 데이터 태그는 경로가 역동적이고 단지 /playvideo 이상이 될 것이기 때문에 android:pathPrefix 대신 android:path을 가질 필요가있다.

두 번째로, 홈 화면은 queryIntentForActivities()을 호출하여 실행하려는 액티비티를 검색하므로 리시버를 Uri를 구문 분석 한 후 실제 재생 활동을 시작한 액티비티로 변경해야했습니다.

내 매니페스트가 대신 있어야하는 내용입니다.

<activity android:name=".channels.PlayVideoActivity"> 
     <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="watchnextcodelab" 
       android:host="com.example.android.watchnextcodelab" 
       android:pathPrefix="/playvideo" /> 
     </intent-filter> 
    </activity>