0

Help please! I need a code for redirecting both mobile and tablet users (all of them) to a different URL. The thing is that i have a flash base web site for desktop users and html 5 for mobile and tablet users so i need a code that will determinate if the user is using mobile(or tablet) and send him to different URL. I've found some jscript that determinates this by checking width of a screen (if (screen.width <= 1024)) but i think that very soon tablets will get bigger screen than 1024 (that is today's biggest standard tablet),so it won't bee usfull anymore .If i put a bigger number than 1024,it will be the same dimension as desktop/laptop screen...

flx
  • 13,818
  • 11
  • 51
  • 69
  • Love to know what you're going to do about Microsoft Surface users. What you really mean is either (a) you want to redirect small screens to a different site, or (b) you want to redirect touchscreen devices to a different site. There's no good reason to pick out tablets and smartphones just because they're tablets and smartphones. – Blazemonger Aug 29 '13 at 13:23
  • Also see [this question](http://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-handheld-device-in-jquery?rq=1). – Blazemonger Aug 29 '13 at 13:26
  • [This](http://stackoverflow.com/questions/15100234/detect-phone-tablet-web-client-using-javascript) could help you. It is another post on Stack Overflow. The question is quite similar to yours. – ClaireG Aug 29 '13 at 13:14

2 Answers2

0

I think if you develope Your website as a responsive site then your problem will be automatically solve.........

OR

Get device width using following code and apply your URL

DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int height = displaymetrics.heightPixels;
int wwidth = displaymetrics.widthPixels;

hope this will help you............

Dhaval Patel
  • 674
  • 4
  • 12
0

For that you have to identify that User has which device>??

For that Try below code...

if (android.os.Build.VERSION.SDK_INT > 10 && android.os.Build.VERSION.SDK_INT <18 ) {

//do stuff

}

else
{
 //do stuff

}
MDroid
  • 550
  • 4
  • 22