• 0

Downloading a webpage is returning the desktop then the mobile


Question

Hey all, I am working on an android app and when downloading a webpage, sometimes I get the mobile version, other times I get the desktop version. Is there some way I can send the user agent? I want to force desktop.

What can I do?

 

This is code I use to get the page


				Scanner sc = null;
				try{
					URL link = new URL(http://somepage.com); 
					sc = new Scanner(link.openStream());
					System.out.println("one");
				}
				catch(Exception e1){
					e1.printStackTrace();
				}	
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

So as far as I can tell, this was the solution

HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0");
Link to comment
Share on other sites

This topic is now closed to further replies.