How to connect a full web site rather than mobile programmatically from android applicaiton

前端 未结 1 934
借酒劲吻你
借酒劲吻你 2021-01-23 02:29

How can I connect to a full web site rather than mobile web page from code? The reason why I ask this is when I try to connect a web site which has a mobile web site, it directs

相关标签:
1条回答
  • 2021-01-23 02:53

    try to set proper header properties e.g. like this:

            conn.setDoOutput(true);
            conn.setRequestProperty("Connection", "Keep-Alive");
            conn.setRequestMethod("GET");
            conn.setDoInput(true);
            conn.setRequestProperty("Accept",
                    "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
            conn.setRequestProperty("Accept-Charset",
                    "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
            conn.setRequestProperty(
                    "User-Agent",
                    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0");
            conn.setRequestProperty("Accept-Language", "en-gb,en;q=0.5");
            conn.setRequestProperty("Referer", "http://youtube.com");
            conn.setRequestProperty("Accept-Encoding", "deflate");
    
    0 讨论(0)
提交回复
热议问题