본문 바로가기

개발

Android TV - Screen Saver Intent

Screen saver 설정 화면으로 이동

    private void startScreenSaver() {
        Intent intent = new Intent("android.settings.DREAM_SETTINGS");
        
        if (!intentAvailable(intent)) {
            // Try opening the daydream settings activity directly: https://gist.github.com/reines/bc798a2cb539f51877bb279125092104
            intent = new Intent(Intent.ACTION_MAIN).setClassName("com.android.tv.settings", "com.android.tv.settings.device.display.daydream.DaydreamActivity");
            if (!intentAvailable(intent)) {
                // If all else fails, open the normal settings screen
                intent = new Intent("android.settings.SETTINGS");
            }
        }
        
        getContext().startActivity(intent);
    }
    
    private boolean intentAvailable(Intent intent) {
        PackageManager manager = getContext().getPackageManager();
        List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);
        return !infos.isEmpty();
    }

 

출처 : stackoverflow.com/questions/62861067/android-tv-set-screensaver-intent

'개발' 카테고리의 다른 글

Android MediaCodec  (0) 2021.02.01
Sample Method (toBinary, fromBinary)  (0) 2020.12.17
Android 11: Developer Preview 3  (0) 2020.05.06
How to get the DNS Information  (0) 2020.04.01
Check whether the IP is in private range  (0) 2020.04.01