Detect tablet or smartphone

Hi!
with cocs2dx in c++, is there a simple way to dectect if my app is running on tablet or on smartphone?
I need this info for tracking/report iusse, not for graphic.
Thanks!
L.

I’m manually calculating the screen size to distinguish between a phone or a tablet, given that everything above 7 inches is a tablet (in my opinion). As far as I know there’s no other solution that works on both ios and android.

int dpi = Device::getDPI();
float xInches = director->getWinSize().width / dpi;
float yInches = director->getWinSize().height / dpi;
float diagonalInches = sqrtf(xInches * xInches + yInches * yInches);
diagonalInches = roundf(diagonalInches * 100.0f) / 100.0f;
bool isTablet = (diagonalInches >= 7.0f);

Thank you very much… I’ll try it out!

Android exposes telecom services through the APIs.

android.telecom
android.telephony

Context.getSystemService(Context.TELECOM_SERVICE);

Maybe you can use those provided APIs.

@domp this is amazing - thank you! :slight_smile:

@domp @gmayer yeah this code has come in handy for me so much…