If you open an mp3 url in the Android's browser, you get a "Complete action using..." dialog window with two options: "Music player", or "Browser". If you choose "Browser" it will download the mp3 to the device.
I'm trying to achieve the same from within my application. I use a WebView with setWebViewClient to a WebViewClient class that has a shouldOverrideUrlLoading method (like in all of the examples). The method checks for an "mp3" extension and startActivity(intent) with a ACTION_VIEW intent on the mp3 url.
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
String lowcaseurl = url.toLowerCase();
if (lowcaseurl.endsWith(".mp3")) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent);
return true;
}
else {
view.loadUrl(url);
}
return super.shouldOverrideUrlLoading(view, url)
}
This does show the "Complete action using" dialog window - but, if I choose "Browser" then the browser opens but doesn't get the url! it just opens the browser and goes to the default "homepage url" (which is google.com in this case)...
Any help will be appreciated.