Jump to content

Android WebView Session Handling

Giddyguy

I'm building an android app with a webview component and am currently implementing how PDFs get opened in the webview. The site I am accessing is our university's course dashboard (where we can access hw, grades, announcements, etc) which requires a login to access the content. In my webview, if i attempt to download and open a PDF posted by an instructor, it redirects the link to the login page even though I am already logged in. However the pdf downloads/opens when accessing the site the Chrome app. Here is my code for downloading:

myView.setDownloadListener(new DownloadListener() {
            public void onDownloadStart(String url, String userAgent,
                                        String contentDisposition, String mimetype,
                                        long contentLength) {
                DownloadManager.Request request = new DownloadManager.Request( Uri.parse(url));
                request.allowScanningByMediaScanner();
                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "temp_file.pdf");
                DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
                dm.enqueue(request);
            }
        });

Is there something I'm missing dealing with cookies/session handling? I'm rather new to android.

Alternatively the same login page is presented if i attempt to load the PDF through the Google Docs Viewer.

 

Thanks in advance.

Delltopia

Case & Mobo: Stock Dell Optiplex 7010, CPU: i5 3470, RAM: 16gb 1333 DDR3 (1x8gb Corsair Vengence, 2x4gb Random), GPU: Diamond Radeon HD 7970,

PSU: EVGA GQ 650W, SSD: Kingston v300 128gb (OS), HDD: 700gb Seagate 7200rpm (Storage)

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×