Implementing a File Dialog in Android TV Leanback

和自甴很熟 提交于 2019-12-04 03:15:58

There is no such picker in Leanback library. if You decide to implement, please note, that Storage Access Framework isn't available in Android TV:

// from AOSP:
// cts/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/
// DocumentsClientTest.java
private boolean supportedHardware() {
    final PackageManager pm = getInstrumentation().getContext().getPackageManager();
    if (pm.hasSystemFeature("android.hardware.type.television") || pm.hasSystemFeature("android.hardware.type.watch")) {
        return false;
    }
    return true;
}

You can check intent.ACTION_GET_CONTENT(with optional Intent.createChooser) to deligate it to other apps, but in my experience it doesn't work on Sony Android TV (still looking into it)

Right now the Storage Access Framework is not part of Android TV, although it is possible to build your own file picker using the GuidedStepFragment to step through folders on the local file system until you find the one you want to select.

You can use any already existing logic for file browsing and implement a dialog with custom view for your case. You can check Es File explorer app for reference. In Android TV you can implement and show to user any view that you wish. The mantra is 'nextFocusDown','nextFocusUP','nextFocusLeft' , 'nextFocusRight' for each view to have a easy navigation between ui components. If you want to present user with an edittext beware as there is no special keyboards like number keyboard etc., present for Leanback.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!