0

I want to detect first what is the platform and the I want to detect is whether it is a phone or tablet. I searched on the internet there are many examples to detect with screen size like height-width, but is there anything which can let what is the device type.

if(Device.RuntimePlatform == Device.iOS)
{
    //what is the device type 
}
else if(Device.RuntimePlatform == Device.Android)
{
    //what is the device type
}
Om Singh
  • 187
  • 3
  • 10
  • What's the difference? Some phones have really big screens, and some tablets have sim cards and are able to make phone calls - including apple tablets. – defaultUsernameN Jun 28 '22 at 14:52
  • There are relevant questions both for android and iOs: https://stackoverflow.com/questions/9279111/determine-if-the-device-is-a-smartphone-or-tablet, https://stackoverflow.com/questions//36699251/how-can-i-get-the-current-device-model-on-xamarin-forms (since ios has a finite range of devices, you can just parse the name and determine if it's a tablet according to your criteria, probably simply by checking ```Contains("IPad")``` – defaultUsernameN Jun 28 '22 at 14:54

1 Answers1

2

Use this to detect device type.


if(Device.RuntimePlatform == Device.iOS)
{
    //what is the device type
   if (Device.Idiom == TargetIdiom.Phone)
   {
       Console.WriteLine(Device.Idiom);
   }
   else if(Device.Idiom == TargetIdiom.Tablet)
   {
       Console.WriteLine(Device.Idiom);
   } 

}
else if(Device.RuntimePlatform == Device.Android)
{
    //what is the device type
}