Dosya barındırıcısından (zippyshare.com gibi) webView kullanarak bir dosyayı indirmeye çalışıyorum. Sorun şu ki, bir tarayıcı açmak için niyetleri kullanamıyorum veya oturum/cookie tabanlı olduğundan ve bu yöntemleri başlatmak için zip dosyasını yeniden yazılmak üzere orijinal html dosyasına yeniden başlatarak DownloadManager üzerinden yeniden yönlendiremiyorum.WebView kullanarak oturum/çerez tabanlı bir dosyayı indirmek için Android'i nasıl kullanabilirim?
Uri source = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(source);
String cookie = CookieManager.getInstance().getCookie(url);
request.addRequestHeader("Set-Cookie", cookie);
request.addRequestHeader("User-Agent", view.getSettings().getUserAgentString());
request.addRequestHeader("Accept", "text/html, application/xhtml+xml, *" + "/" + "*");
request.addRequestHeader("Accept-Language", "en-US,en;q=0.7,he;q=0.3");
request.addRequestHeader("Referer", url);
// Use the same file name for the destination
final File destinationDir = new File (Environment.getExternalStorageDirectory(), cordova.getActivity().getPackageName());
if (!destinationDir.exists()) {
destinationDir.mkdir(); // Don't forget to make the directory if it's not there
}
File destinationFile = new File (destinationDir, source.getLastPathSegment());
Log.e("FILEPOSITION", Uri.fromFile(destinationFile).toString());
request.setDestinationUri(Uri.fromFile(destinationFile));
// Add it to the manager
manager.enqueue(request);
ve:
denedim
Bundle bundle = new Bundle();
String cookie = CookieManager.getInstance().getCookie(url);
bundle.putString("cookie", cookie);
bundle.putString("User-Agent", view.getSettings().getUserAgentString());
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse(url));
intent.putExtra(Browser.EXTRA_HEADERS, bundle);
cordova.getActivity().startActivity(intent);
çerez korumak için denemek için, ve ben başlıkları gayet gönderilir görürken, hala html linke yönlendirir Bu, oturum temelli olduğuna inanmamı sağlıyor.
Dosyayı bu şekilde indirmenin bir yolu var mı?
Teşekkürler tobik, akşam bakacağım, umarım işe yarar :) – trueicecold