Posted By

Klostrag on 12/22/12


php simple detection mobile with user and agent Smartphone Redirction

Versions (?)

Simple User Agent (Mobile and Smartphone) Detection and Redirction with PHP

 / Published in: Java

This is similar to the one for PHP but modified for JAVA.

  1. String UserAgent = req.getHeader("User-Agent");
  2. if(UserAgent.toLowerCase().replace(' ', '%').matches("\\p{Graph}*"
  3. +"(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser||"
  4. +"htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|"
  5. +"blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|"
  6. +"symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmmm|"
  7. +"jigs browser|hiptop|^ucweb|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220)"
  8. +"\\p{Graph}*")){
  9. System.out.println("ENTRY_MODE = Mobile");
  10. }
  11. else{
  12. System.out.println("ENTRY_MODE = Web");
  13. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: Klostrag on December 22, 2012

Ugh I can´t edit nor delete this... The title was suppossed to say JAVA instead of PHP

You need to login to post a comment.