WebView webview;
webview = new WebView(this);
webview.layout(0, 0, 0, 0);
WebSettings settings = webview.getSettings();
String ua = settings.getUserAgentString(); //获取手机内部浏览器UA
注:必须放在activity中,否则会出现空指针异常
URL myUrl = new URL(searchURL);//参数是url
HttpURLConnection myConn = (HttpURLConnection)myUrl.openConnection();//打开连接
myConn.setRequestProperty("User-agent",ua);//为连接设置ua