Return to Snippet

Revision: 61578
at December 22, 2012 01:56 by Klostrag


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

Initial URL

                                

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

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

Initial Tags
php, simple, mobile, user

Initial Language
Java