【发布时间】:2016-03-08 17:05:51
【问题描述】:
我在 Android 中使用蓝牙开发了一个运行良好的应用,但在 Android TV 中尝试时遇到了一些问题。
根据Bluetooth tutorial,我用它来让我的设备可被发现:
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);
它在普通设备上运行良好,但在 Android TV 中,我得到一个ActivityNotFoundException:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.bluetooth.adapter.action.REQUEST_DISCOVERABLE (has extras) }
如果我理解得很好,这个异常意味着默认情况下没有活动向用户询问请求(我认为默认对话框询问权限)。
那么有没有办法创建我们自己的种活动(来处理这种行为)或者可能不向用户询问许可。或者当然,可能是我的方法完全错误。
我不知道它是否有用,但我正在 Nvidia SHIELD TV 上开发。
【问题讨论】:
标签: android bluetooth android-tv