0

有没有办法访问用户在设置 Google TV 时指定的电视提供商?例如,我的邮政编码设置包括 Comcast、Dish、DirecTV 等电视提供商。

我的应用复制了这个设置小部件,因为它也需要知道用户的电视提供商。相反,我想向 Google TV 系统询问用户已经进行的设置。

4

2 回答 2

1

提供者的 URI 已在最新更新中从content://com.google.android.tv.provider/devices更改为content://com.google.tv.mediadevicesapp.MediaDevicesProvider/devices

 DEVICE_ID = "device_id";   // like Atsc01
 LINEUP_ID = "lineup_id";   // like TMS:OTA94043
 DEFAULT = "is_default";    // 0 or 1  -- Also changed from "default"

自从我在去年的发行说明中提到它以来,我在这里回答这个问题。由于使用这是一个罕见的用例,因此无法保证我们会长期支持它。

于 2013-03-25T22:51:58.063 回答
0

您无法获取服务提供商信息,但可以获取位置。使用“静态”位置提供程序从设备设置期间配置的邮政编码获取位置:

LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
Location location = locationManager.getLastKnownLocation("static");
Geocoder geocoder = new Geocoder(this);
Address address = null;
try {
  address = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1).get(0);
  Log.d("Zip code", address.getPostalCode());
} catch (IOException e) {
  Log.e(TAG, "Geocoder error", e);
}  

清单中需要“android.permission.ACCESS_COARSE_LOCATION”权限。

于 2013-03-21T00:45:44.253 回答