Thursday, July 07, 2011

Detect device is an Android Tablet or not

public static int DISPLAY_SCREEN_WIDTH = 0;
public static int DISPLAY_SCREEN_HEIGHT = 0;
private int MAX_PHONE_WIDTH = 500;
private int MAX_PHONE_HEIGHT = 800;
private boolean isDeviceATablet() {
boolean bIsDeviceATablet = false;

Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
DISPLAY_SCREEN_WIDTH = display.getWidth();
DISPLAY_SCREEN_HEIGHT = display.getHeight();


if( (DISPLAY_SCREEN_WIDTH > MAX_PHONE_WIDTH) || (DISPLAY_SCREEN_HEIGHT > MAX_PHONE_HEIGHT) )
bIsDeviceATablet = true;
if(bIsDeviceATablet)
Log.i("Device is identified as an Android TABLET.");
else
Log.i("Device is identified as an Android PHONE.");

return bIsDeviceATablet;
}

No comments:

Create a list in SwiftUI with sticky section headers

 Sample Code import SwiftUI struct ContentView : View {     @State var isCustomViewControllerDisplayed = false     @State private va...