Displaying Remote PDF via Intent with Basic Auth

I am trying to show a PDF located at http://myserver.com/my_file.pdf . Basic authentication exists for this endpoint. I'm doing it:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://myserver.com/my_file.pdf"));
Bundle bundle = new Bundle();
bundle.putString("Authorization", "Basic xxxxxxxxxxxxxxxxxxxx");
intent.putExtra(Browser.EXTRA_HEADERS, bundle);
startActivity(intent);

      

But when I debug server side, there is no header in the request Authorization

, so I get 401 Unauthorized.

What am I doing wrong?

0


source to share


1 answer


Since you cannot share the exact url, I would suggest that you open this in webview in your application.



webView.setJavaScriptEnabled(true);
webview.loadUrl(<URL>);

      

0


source







All Articles