Hallo Pascal,
ich habe jetzt diesen Code:
// This will handle downloading. It requires Gingerbread, though
final DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
// This is where downloaded files will be written, using the package name isn't required
// but it's a good way to communicate who owns the directory
final File destinationDir = new File (Environment.getExternalStorageDirectory(), getPackageName());
if (!destinationDir.exists()) {
destinationDir.mkdir(); // Don't forget to make the directory if it's not there
}
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading (WebView view, String url) {
boolean shouldOverride = false;
// We only want to handle requests for mp3 files, everything else the webview
// can handle normally
if (url.endsWith(".mp3")) {
shouldOverride = true;
Uri source = Uri.parse(url);
// Make a new request pointing to the mp3 url
DownloadManager.Request request = new DownloadManager.Request(source);
// Use the same file name for the destination
File destinationFile = new File (destinationDir, source.getLastPathSegment());
request.setDestinationUri(Uri.fromFile(destinationFile));
// Add it to the manager
manager.enqueue(request);
}
return shouldOverride;
}
});
gefunden aber ich weiß nicht genau wo ich den einbauen soll, könnte ich dir den Code schicken von meiner WebView Activity und du würdest den einpflegen???
Gruß Fredi