android 系統UI模式的判斷

2021-07-24 07:05:19 字數 2619 閱讀 2784

目前我們強大的android系統已經遍及手機,電視,等各個方面。

那麼如何判斷乙個android系統 是支援手機ui 還是 boxui呢。 如果知道這一屬性,那麼我們就可以在開發應用程式的時候對這個屬性做判斷(比如讓我們的手機應用不能執行在box上)。怎麼做到這一點呢, 今天我就給大家帶來方法:

uimodemanager

muimodemanager = (uimodemanager)getsystemservice(context.ui_mode_service);

muimodemanager.getcurrentmodetype();

uimodemanager 就是用來獲取android 系統配置的ui模式, 通過getcurrentmodetype(),就可以拿到模式型別。

/** constant for : bits that encode the mode type. */

public static final int ui_mode_type_mask = 0x0f;

/** constant for : a

* value indicating that no mode type has been set. */

public static final int ui_mode_type_undefined = 0x00;

/** constant for : a

* value that corresponds to

* guide/topics/resources/providing-resources.html#uimodequalifier">no

* ui mode resource qualifier specified. */

public static final int ui_mode_type_normal = 0x01;

/** constant for : a

* value that corresponds to the

* guide/topics/resources/providing-resources.html#uimodequalifier">desk>

* resource qualifier. */

public static final int ui_mode_type_desk = 0x02;

/** constant for : a

* value that corresponds to the

* guide/topics/resources/providing-resources.html#uimodequalifier">car>

* resource qualifier. */

public static final int ui_mode_type_car = 0x03;

/** constant for : a

* value that corresponds to the

* guide/topics/resources/providing-resources.html#uimodequalifier">television>

* resource qualifier. */

public static final int ui_mode_type_television = 0x04;

/** constant for : a

* value that corresponds to the

* guide/topics/resources/providing-resources.html#uimodequalifier">watch>

* resource qualifier. */

public static final int ui_mode_type_watch = 0x06;

/** constant for : bits that encode the night mode. */

public static final int ui_mode_night_mask = 0x30;

/** constant for : a

* value indicating that no mode type has been set. */

public static final int ui_mode_night_undefined = 0x00;

/** constant for : a

* value that corresponds to the

* guide/topics/resources/providing-resources.html#nightqualifier">notnight>

* resource qualifier. */

public static final int ui_mode_night_no = 0x10;

/** constant for : a

* value that corresponds to the

* guide/topics/resources/providing-resources.html#nightqualifier">night>

* resource qualifier. */

public static final int ui_mode_night_yes = 0x20;

Android系統螢幕UI重新整理機制

人眼舒適放鬆時可視幀數是每秒24幀,集中精神時不超過30幀,眨眼時睜開眼瞬間可以捕捉到的幀數是30幀以上,遊戲所說的60幀所能造成的就是畫面不閃爍,更流暢。在一秒內重新整理螢幕的次數,例如60hz,即16ms一次,重新整理率越高越好。gpu在一秒內操作畫面的次數,例如30fps,60fps,幀率越高...

android的Handler進行UI更新

handle處理不同執行緒之間的資料傳輸,每乙個執行緒建立後會與乙個looper關聯,looper管理message佇列的地方吧,handle是傳送message的運送東西,looper可以與多個handler關聯,在主線程中handler建立後會與主線程關聯,在子執行緒中通過 handler.se...

單例模式的雙重判否

在單例模式的懶漢模式中,getinstance方法通常是採用如下方式寫的 public static stest getinstance return stest 這樣的寫法在多執行緒的情況下有可能造成不同的執行緒都例項化了乙個物件出來,所以該寫法是執行緒不安全的。那麼怎麼辦呢?首先,自然想到既然執...