i use this code to log on a secure page and even i've loged in, i can't
download pdf files which are located at that site. The download procedure
restarts continuously and fiannly the download manager thells me that the
download failed. The code:
private void openBrowser() {
webviewlagie.post(new Runnable() {
@Override
public void run() {
//webviewlagie.setWebChromeClient(new
WebChromeClient());
webviewlagie.setInitialScale(1);
webviewlagie.getSettings().setJavaScriptEnabled(true);
webviewlagie.getSettings().setLoadWithOverviewMode(true);
webviewlagie.getSettings().setUseWideViewPort(true);
webviewlagie.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webviewlagie.setScrollbarFadingEnabled(false);
//zoom
webviewlagie.getSettings().setBuiltInZoomControls(true);
webviewlagie.getSettings().setSupportZoom(true);
//zoom
//webviewlagie.getSettings().setAllowFileAccessFromFileURLs(true);
webviewlagie.loadUrl(("https://mySecureSite.com"));
webviewlagie.setWebViewClient(
new SSLTolerentWebViewClient() {
public void onPageFinished(WebView view,
String url) {
view.loadUrl("javascript:document.getElementById('email').value = '" +
MyEmail + "';document.getElementById('password').value='" + MyPassword +
"';");
//view.loadUrl("javascript:confirmSubmit()");
view.loadUrl("javascript:(function(){document.getElementById('Connect').click();})()");
}
@Override
public void onReceivedError(WebView view,
int errorCode,
String
description, String failingUrl) {
Log.d("WEB_VIEW_TEST", "error code:" +
errorCode + " - " + description);
}
@Override
public boolean
shouldOverrideUrlLoading(WebView view, String url) {
// handle different requests for
different type of files
// this example handles downloads
requests for .apk and .mp3 files
// everything else the webview can
handle normally
Log.d("MyCameraApp", "failed to create
directory");
if (url.endsWith(".apk")) {
Uri source = Uri.parse(url);
// Make a new request pointing to
the .apk url
DownloadManager.Request request =
new DownloadManager.Request(source);
// appears the same in Notification
bar while downloading
request.setDescription("Description
for the DownloadManager Bar");
request.setTitle("YourApp.apk");
if (Build.VERSION.SDK_INT >=
Build.VERSION_CODES.HONEYCOMB) {
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
// save the file in the "Downloads"
folder of SDCARD
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,
"SmartPigs.apk");
// get download service and enqueue
file
DownloadManager manager =
(DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
} else if (url.endsWith(".mp3")) {
// if the link points to an .mp3
resource do something else
} else if
(url.startsWith("https://ape.desmie.gr/Producerprofile/displaymemo/yearmonth/"))
{
Log.d("Pas downlo ", url);
/*DownloadManager.Request request =
new DownloadManager.Request(Uri.parse(url));
request.allowScanningByMediaScanner();
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,
"app_download_directory");
DownloadManager dm =
(DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);*/
Uri source = Uri.parse(url);
// Make a new request pointing to
the .apk url
DownloadManager.Request request =
new DownloadManager.Request(source);
// appears the same in Notification
bar while downloading
request.setDescription("Description
for the DownloadManager Bar");
request.setTitle("YourApp.pdf");
if (Build.VERSION.SDK_INT >=
Build.VERSION_CODES.HONEYCOMB) {
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
// save the file in the "Downloads"
folder of SDCARD
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,
"SmartPigs.pdf");
// get download service and enqueue
file
DownloadManager manager =
(DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
// if the link points to an .mp3
resource do something else
// if there is a link to anything else
than .apk or .mp3 load the URL in the webview
}
else {
view.loadUrl(url);
Log.d("MyCameraApp 2", "failed to
create directory");
Log.d("Pas 2",url);
}
return true;
}
}
);
webviewlagie.requestFocus();
}
});
}
the onCreate void
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(webviewlagie != null){
webViewParentViewGroup.removeView(webviewlagie);
setContentView(R.layout.activity_main_no_webview);
webViewParentViewGroup = (ViewGroup)
findViewById(R.id.secondViewGroup);
webViewParentViewGroup.addView(this.webviewlagie);
} else {
setContentView(R.layout.activity_http_url_connection_example);
webViewParentViewGroup = (ViewGroup)
findViewById(R.id.firstViewGroup);
webviewlagie = (WebView)
findViewById(R.id.webviewlagie);
//configure WebView - left out here for brevity
}
openBrowser();
}
when i change this part of code:
Uri source = Uri.parse(url);
// Make a new request pointing to
the .apk url
DownloadManager.Request request =
new DownloadManager.Request(source);
// appears the same in Notification
bar while downloading
request.setDescription("Description
for the DownloadManager Bar");
request.setTitle("YourApp.pdf");
if (Build.VERSION.SDK_INT >=
Build.VERSION_CODES.HONEYCOMB) {
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
// save the file in the "Downloads"
folder of SDCARD
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,
"SmartPigs.pdf");
// get download service and enqueue
file
DownloadManager manager =
(DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
with this one:
view.loadUrl("http://docs.google.com/gview?embedded=true&url="
+ url);
the google gview show me the parents site html code.
Any idea of the problem?
Thanks in advance
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.