3 posts in this topic

Posted

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();
				}	

Share this post


Link to post
Share on other sites

Posted

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");

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.