有没有办法访问用户在设置Google TV时指定的电视提供商?例如,我的邮政编码设置包括Comcast,Dish,DirecTV等电视提供商。
我的应用重复此设置小部件,因为它也需要知道用户的电视提供商。相反,我想向Google TV系统询问用户已经设置的设置。
答案 0 :(得分:1)
最新更新中提供商更改的URI已从 content://com.google.android.tv.provider/devices 更改为 content://com.google.tv .mediadevicesapp.MediaDevicesProvider /设备
DEVICE_ID = "device_id"; // like Atsc01
LINEUP_ID = "lineup_id"; // like TMS:OTA94043
DEFAULT = "is_default"; // 0 or 1 -- Also changed from "default"
我在这里回答这个问题,因为我去年在发行说明中提到了这一点。由于使用它是一种罕见的用例,因此无法保证我们会长期支持它。
答案 1 :(得分: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”权限。