Skip to Content
avatar image
Former Member

SAPUI5: What is the best Reliable way to detect on which device my app is running?

Hi,

I have developed a sapui5 app that can run on iPhone, iPad, and desktop. Depending on the running media, it will use different theme or UIs. The are several ways of detecting OS, device or screen resolutions, such as:

navigator.userAgent.match(/(iPhone)/g)

window.devicePixelRatio ==2

scree.width()

iQuery.device.is.phone

$('#phone').css('display') == 'none'

My question: what is the best and Reliable way in the code to find out which of the following devices my app is running on:

"iPhone" (valid for all kinds of resolutions)

"iPad" (all possible types)

"laptop/desktop"

Thanks.

Sr. Sys Developer●Enterprise Mobility●SAP●iOS●Web●Android

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 21, 2014 at 01:49 PM

    i think you should be using the Device apis, available under sap.ui.device

    https://sapui5.hana.ondemand.com/sdk/#docs/api/symbols/sap.ui.Device.system.html

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Andreas Kunz

      Hi Sandip and Andreas,

      Thanks for your comments. The deatils below works fine so far. Br, /Dong

      jQuery.device.is.android_phone

      jQuery.device.is.android_tablet

      jQuery.device.is.desktop

      jQuery.device.is.ipad

      jQuery.device.is.iphone

      jQuery.device.is.landscape

      jQuery.device.is.phone

      jQuery.device.is.portrait

      jQuery.device.is.standalone

      jQuery.device.is.tablet