Skip to content

Commit e7c9ba3

Browse files
authored
Merge pull request #222 from HugoCastelani/patch-1
Add isTablet method
2 parents 66869a9 + ee77cca commit e7c9ba3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

utilcode/src/main/java/com/blankj/utilcode/util/ScreenUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,15 @@ public static int getSleepDuration() {
174174
return -123;
175175
}
176176
}
177+
178+
/**
179+
* Check if the device is a tablet based on screen size
180+
*
181+
* @return {@code true}: Yes<br>{@code false}: No
182+
*/
183+
public static boolean isTablet() {
184+
return (Utils.getContext().getResources().getConfiguration().screenLayout
185+
& Configuration.SCREENLAYOUT_SIZE_MASK)
186+
>= Configuration.SCREENLAYOUT_SIZE_LARGE;
187+
}
177188
}

0 commit comments

Comments
 (0)