SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jan 2012
    Location
    Philippines
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    The client is using Android....

    From time to time I have been encoding classic ASP pages for my use.

    Using the MobileESP Classic ASP source code;
    https://bitbucket.org/mbarrero/mobil....asp?at=master

    How can I check whether the client is using the usual desktop PC... or an android tablet on my ASP page?? The link only includes the source code on how to detect the clients browser if it is regular desktop or android tablet, but it does not elaborate how to use it.

  2. #2
    SitePoint Member fun8848's Avatar
    Join Date
    Feb 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use javascript, such as...

    <script type="text/javascript">
    if (screen.width<600)
    window.location = "./mobile/";
    </script>
    Buy visitors as low as 0.01 cent per unique visitor.
    The easiest way to improve alexa ranking effectively, full refund guaranteed!

  3. #3
    SitePoint Member
    Join Date
    Jan 2012
    Location
    Philippines
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool Detecting Mobile Devices in Classic ASP

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%
    Dim user_agent, mobile_browser, Regex, match, mobile_agents, mobile_ua, i, size
    user_agent = Request.ServerVariables("HTTP_USER_AGENT")
    mobile_browser = 0
    Set Regex = New RegExp
    With Regex
      .Pattern = "(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm)"
      .IgnoreCase = True
      .Global = True
    End With
    match = Regex.Test(user_agent)
    If match Then mobile_browser = mobile_browser+1
      If InStr(Request.ServerVariables("HTTP_ACCEPT"), "application/vnd.wap.xhtml+xml") Or Not IsEmpty(Request.ServerVariables("HTTP_X_PROFILE")) Or Not IsEmpty(Request.ServerVariables("HTTP_PROFILE")) Then
        mobile_browser = mobile_browser+1
      End If
      'list of devices, this is an array so just add more that come to the marketplace into here
      mobile_agents = Array("alcatel", "amoi", "android", "avantgo", "blackberry", "benq", "cell", "cricket", "docomo", "elaine", "htc", "iemobile", "iphone", "ipad", "ipaq", "ipod", "j2me", "java", "midp", "mini", "mmp", "mobi", "motorola", "nec-", "nokia", "palm", "panasonic", "philips", "phone", "sagem", "sharp", "sie-", "smartphone", "sony", "symbian", "t-mobile", "telus", "up\.browser", "up\.link", "vodafone", "wap", "webos", "wireless", "xda", "xoom", "zte")
      size = Ubound(mobile_agents)
      mobile_ua = LCase(Left(user_agent, 4))
      For i = 0 To size
        If mobile_agents(i) = mobile_ua Then
          mobile_browser = mobile_browser+1
          Exit For
        End If
      Next
      'check that full website has not been requested (you can have a link in the page for this like: view Full Site
      If request.querystring("v")="full" then session("fullsite")=true
      If mobile_browser>0 and session("fullsite")=false then
        response.redirect("tablet.asp")
    End If
    %>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    I got it! I took a sample codes out there (somewhere), forgot where I took the codes out but I Googled it... and has been using since. It really simple, just load you main page as usual except that the code above will be evaluated first. If the condition is tested as a mobile device... then redirect your page to tablet.asp

    It works for me.


  4. #4
    SitePoint Member
    Join Date
    Jun 2010
    Location
    San Jose California
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try to use this code:

    Code ASP:
    public void recieveMessage()
    {  
     
               Log.e("xmppclient","will receive messages");
               PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
               connection.addPacketListener(new PacketListener() {
     
               public void processPacket(Packet packet) {
                   if(connection != null && connection.isConnected()) 
                   {
                       Message message = (Message) packet;
                       if (message.getBody() != null)
                            {
                       fromName = StringUtils.parseBareAddress(message.getFrom());
                       String messageBody=message.getBody();
                       Log.e("Message", messageBody );
                       Intent i = new Intent(NEW_MESSAGE);  
                       i.putExtra("username", StringUtils.parseBareAddress(message.getFrom()));
                       i.putExtra("message", message.getBody());
                       sendBroadcast(i);
                            }
                       else
                       {
     
                           connectToXmpp();
                       }
                   }
     
                }
     
               }
       ,filter);
       }
    Last edited by Mittineague; Feb 26, 2013 at 14:00.

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,609
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    How will that help? That's ASP .NET
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •