반응형
* Server Side에서 HTTP Request Header중 User Agent값을 이용하여 사용자가 현재 접속한 단말기가 어떤 것인지 구분이 가능함
요 위의 샘플은 아래 사이트를 참고하자.
Reference
[1] http://user-agents.my-addr.com/user_agent_request/user_agent_examples-and-user_agent_types.php
[2] http://blog.naver.com/PostView.nhn?blogId=webscaler&logNo=70105446972
Java Web Server
public final void doGet(HttpServletResponse res)
throws ServletException, IOException{
String agent = req.getHeader("user-agent");
if(agent != null){
if(agent.toUpperCase().indexOf("IPHONE") > -1){
// iPhone Mode
}else if(agent.toUpperCase().indexOf("IPAD") > -1){
// iPad Mode
}else if(agent.toUpperCase().indexOf("ANDROID") > -1){
// Android Mode
}
}
}
ASP.NET Web Server
<%@ Page language="C#"%>
<script runat="server">
private string_Message;
private void Page_Load(Object sender, System.EventArgs e)
{
String agent = Request.UserAgent;
if(agent.ToUpper().indexOf("IPHONE") > -1){
// iPhone Mode
}else if(agent.ToUpper().indexOf("ANDROID") > -1){
// Android Mode
}
}
</script>
<html></html>
JavaScript
<script type="text/javascript">
var agent = navigator.userAgent;
if(agent.toUpperCase().indexOf("IPHONE") > -1){
// iPhone Mode
} else if(agent.toUpperCase().indexOf("ANDROID") > -1){
// Android Mode
}
</script>
Device | HTTP User Agent Header Sample |
---|---|
iPhone | Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_0 likeMac OS X; ja-jp) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1Mobile/5A345 Safari/525.20 |
iPad | ... |
Android | ... |
BackBerry | ... |
Windows Phone 7 | ... |
Bada | ... |
요 위의 샘플은 아래 사이트를 참고하자.
Reference
[1] http://user-agents.my-addr.com/user_agent_request/user_agent_examples-and-user_agent_types.php
[2] http://blog.naver.com/PostView.nhn?blogId=webscaler&logNo=70105446972
Java Web Server
throws ServletException, IOException{
String agent = req.getHeader("user-agent");
if(agent != null){
if(agent.toUpperCase().indexOf("IPHONE") > -1){
// iPhone Mode
}else if(agent.toUpperCase().indexOf("IPAD") > -1){
// iPad Mode
}else if(agent.toUpperCase().indexOf("ANDROID") > -1){
// Android Mode
}
}
}
ASP.NET Web Server
<script runat="server">
private string_Message;
private void Page_Load(Object sender, System.EventArgs e)
{
String agent = Request.UserAgent;
if(agent.ToUpper().indexOf("IPHONE") > -1){
// iPhone Mode
}else if(agent.ToUpper().indexOf("ANDROID") > -1){
// Android Mode
}
}
</script>
<html></html>
JavaScript
var agent = navigator.userAgent;
if(agent.toUpperCase().indexOf("IPHONE") > -1){
// iPhone Mode
} else if(agent.toUpperCase().indexOf("ANDROID") > -1){
// Android Mode
}
</script>
반응형
'Devlopment > Mobile' 카테고리의 다른 글
Android Camera (0) | 2011.06.22 |
---|---|
Android Drawing (0) | 2011.06.21 |
안드로이드 OS Version 및 이름 (0) | 2011.06.20 |
Eclipse에서 안드로이드 개발시 Device가 안 잡힐 경우 (0) | 2011.06.17 |
Mobile UI Framework (0) | 2011.06.16 |
jQuery Mobile 기본 코딩 (0) | 2011.06.16 |
Hybrid App (0) | 2011.06.16 |
Mobile UI/UX Guideline (0) | 2011.06.15 |
App 개발 환경 (0) | 2011.06.13 |
구글맵 API 받기 (0) | 2010.08.31 |