Search code examples
androiduser-agentandroid-browserhttp-request

Browser Intent with User-Agent


I'm trying to open the Android browser through a Intent with a custom User-Agent (cause the client website redirects to the mobile page) as far as I got is:

            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse("http://www.clientwebsite.com"));
            Bundle bundle = new Bundle();
            bundle.putString("User-Agent", "desktop");
            i.putExtra(Browser.EXTRA_HEADERS, bundle);
            startActivity(i);

But this is still being redirected to Mobile page.

What is a valid User-Agent to identify a not-mobile user? Setting User-Agent on EXTRA_HEADERS of the Intent really modify this header or it's overridden by the Browser?


Solution

  • Well, I solved creating my own WebActivity with the User-Agent as 'desktop'.

        web.getSettings().setUserAgentString("desktop");