如果您使用下面的代码,对提供程序的访问已经改变,事情应该会有所改善。
权限:
<uses-permission android:name="com.google.android.tv.permission.READ_CHANNELS"/>
<uses-permission android:name="com.google.android.tv.mediadevices.permission.READ_STREAMS"/>
代码:
public abstract class ChannelList {
private static ChannelList mCL=null;
public abstract String getPROVIDER_URI();
public abstract String getCALL_SIGN_COLUMN();
public abstract String getURI_COLUMN();
public abstract String getNUMBER_COLUMN();
public abstract String getNAME_COLUMN();
public static ChannelList getChannelList() {
if (mCL != null)
return mCL;
int mGtvLibraryVersion = 0;
try {
Class<?> cl = Class.forName("com.google.android.tv.Version");
mGtvLibraryVersion = cl.getField("GTV_SDK_INT").getInt(null);
} catch (Exception ex) {}
Log.d("Resolution Test", "Version " + mGtvLibraryVersion);
mCL= mGtvLibraryVersion > 0 ? new Version3ChannelList(): new Version2ChannelList();
return mCL;
}
/**
* Use the getChannelList factory to obtain an instance of a subclass of
* ChannelList
*/
private ChannelList() {
}
@Override
public String toString() {
return "SDK Provider: " + getPROVIDER_URI() + "\n" +
"Columns: " + getCALL_SIGN_COLUMN() + " " + getURI_COLUMN() + " " + getNUMBER_COLUMN() + " "
+ getNAME_COLUMN();
}
public static final class Version2ChannelList extends ChannelList {
@Override
public String getPROVIDER_URI() {
return "content://com.google.android.tv.provider/channel_listing";
}
@Override
public String getCALL_SIGN_COLUMN() {
return "callsign";
}
@Override
public String getURI_COLUMN() {
return "channel_uri";
}
@Override
public String getNUMBER_COLUMN() {
return "channel_number";
}
@Override
public String getNAME_COLUMN() {
return "channel_name";
}
}
public static final class Version3ChannelList extends ChannelList {
@Override
public String getPROVIDER_URI() {
return "content://com.google.tv.mediadevicesapp.MediaDevicesProvider/channel_list";
}
@Override
public String getCALL_SIGN_COLUMN() {
return "subName";
}
@Override
public String getURI_COLUMN() {
return "url";
}
@Override
public String getNUMBER_COLUMN() {
return "channelNumber";
}
@Override
public String getNAME_COLUMN() {
return "name";
}
}