让TV默认触摸模式

一般Android TV 是遥控模式,但是有的TV是有触屏的。我们想开机默认没有任何控件获取焦点这时候就得设置当前的控制模式为触屏模式。
设置触屏模式代码如下 ,建议在application中设置

new Instrumentation().setInTouchMode(true);
 /**
     * Force the global system in or out of touch mode.  This can be used if
     * your instrumentation relies on the UI being in one more or the other
     * when it starts.
     * 
     * @param inTouch Set to true to be in touch mode, false to be in
     * focus mode.
     */
    public void setInTouchMode(boolean inTouch) {
        try {
            IWindowManager.Stub.asInterface(
                    ServiceManager.getService("window")).setInTouchMode(inTouch);
        } catch (RemoteException e) {
            // Shouldn't happen!
        }
    }

RT

猜你喜欢

转载自blog.csdn.net/qq910689331/article/details/119389566
今日推荐