简体   繁体   中英

Password-protected web pages when accessed by Android

I have created a password protected static html page with a custom audio player, to be displayed in any browser and OSs. User/password access to the page works fine from any browser. But none of my attempts to make the player work for Android browsers worked. This is the link I have:

   <a title="play mp3 in new window" target="_blank" href="01.mp3"><img border="0" src="play.gif"></a>

If I remove the password, the player works in Android as well, so this would suggest an issue with playing media files on Android when the directory is password protected. The files are indeed in the same folder as the web page.

Thanks for any help,

Joe

You have to add your autorization to the webview headers:

Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "Basic" + Base64.encodeToString(username + ':' + password),Base64.DEFAULT);

And then when you load your url add the headers as the second parameter.

webview.loadUrl("www.mysite.com",headers);

You can also use setHttpAuthUsernamePassword

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM