0
votes

I am developing an app using xamarin forms cross-platform PCL project. I need to know if I can detect whether the device is touch device or not? Is it possible to detect this?

2
Are you planning to make a TV app ? is that why you are asking ? if so you can know that from the android project in main activity. - Ahmad ElMadi
@BraveHeart how? do you have sample code - Sonali
I have sent you the sample , does that answer you question ? - Ahmad ElMadi
yes it helped. thank you @BraveHeart - Sonali

2 Answers

2
votes

XF does not know if the device is touch or not, but you can detect the kind of device you're running on using Device.Idiom. If you get TargetIdiom.Desktop you know that, in addition of a possible touch screen, the user probably also has a keyboard and a mouse.

1
votes

I suppose you are asking this to make a TV app . Well unfortunatly at this moment Xamarin.Forms cannot find that, however you can do this in the main Activity like follows

 var uiModeManager = (UiModeManager) GetSystemService(UiModeService);
if (uiModeManager.CurrentModeType == UiMode.TypeTelevision)
{
     _isTv = true;

}
else
{
_isTv = false;

}