一般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!}}