2

I want to display a .pdf file in WebView which is having authentication. The app has been rejected by Google as I am using intent to load the WebView

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://UserName:password@myUrl", "text/html");mContext.startActivity(intent);
Krishna Raj Salim
  • 7,331
  • 5
  • 34
  • 66

1 Answers1

0

You can't use https://username:password@url in android, unfortunately.

You have to add Basic Authorization in the Request Property in a bundle

Bundle bundle = new Bundle();
String basicAuth = USERNAME + ":" + PASSWORD
basicAuth = "Basic " + new String(Base64.encode(basicAuth.getBytes(),Base64.NO_WRAP));
bundle.putString("Authorization", basicAuth);
intent.putExtra(Browser.EXTRA_HEADERS, bundle);

you may also need:

webView.setJavaScriptEnabled(true);
webview.loadUrl(<URL>);
Dylan Ang
  • 175
  • 7