Skip to content Skip to sidebar Skip to footer

Adding Custom Headers On All Browsers

I am working on a application where i want to add headers to browser in android. Its working pretty fine on Google chrome. But this is not working on other available browsers like

Solution 1:

There is no requirement that browsers pay any attention to extras like EXTRA_HEADERS, REQUEST_HEADER_TOKEN, etc.

Either use WebView or live without the headers always being added.

Solution 2:

This solution definitely works with mobile chrome browser ( haven't test ob others)

IntentmIntent=newIntent(Intent.ACTION_VIEW,Uri.parse(URL));
    Bundlebundle=newBundle();
    bundle.putString("Authorization", "Basic " + token);
    mIntent.putExtra(Browser.EXTRA_HEADERS, bundle);
    startActivity(mIntent);

However be careful with links for files that can be opened in some other default application.

In my case, there was problem with pdf Every link that ends with .pdf (http://lol.com/test.pdf) is opening not in web browser but in some pdf reader and then EXTRA_HEADERS aren't sent.

Post a Comment for "Adding Custom Headers On All Browsers"