Track the last redirected url android -


iam loading web page webview. login page. when user enters credentials page redirects multiple times. want track last redirected url.

any idea on how can done.

here code:

mywebview.setwebviewclient(new webviewclient() {

            @override             public void onpagefinished(webview view, string url)              {                 // todo auto-generated method stub                 super.onpagefinished(view, url);                 if(progressbar.isshowing())                 {                     progressbar.dismiss();                 }                 string absoluteurl = view.geturl();                 absoluteurl = uri.decode(absoluteurl);                 int absoultecount = absoluteurl.length();                  string redirectedurl = endpointhost+"authorize/index"+deviceid;                 int redirectedcount = redirectedurl.length();                   alertdialog.builder alertdialogbuilder = new alertdialog.builder(details.this);                 alertdialogbuilder.setnegativebutton("ok", new dialoginterface.onclicklistener()                  {                     public void onclick(dialoginterface dialog,int id)                      {                         // if button clicked, close                         // dialog box , nothing                         dialog.cancel();                     }                 });                 alertdialog alert = alertdialogbuilder.create();                 alert.setmessage(absoluteurl);                 alert.show();               }             @override             public boolean shouldoverrideurlloading(webview view, string url)             {                 // todo auto-generated method stub                 view.loadurl(url);                  httpclient httpclient = new defaulthttpclient();                 url myurl;                 urlconnection connection;                 try                 {                     myurl = new url(url);                     connection = myurl.openconnection();                     connection.setconnecttimeout(3000);                     connection.connect();                      int size = connection.getcontentlength();                  }                 catch (exception e) {}                  string htmlcontent = "";                 httppost httpget = new httppost(url);                 httpresponse response;                 httpcontext httpcontext = new basichttpcontext();                 try                 {                     response = httpclient.execute(httpget);                       if(response.getstatusline().getstatuscode() == 200)                     {                         httpentity entity = response.getentity();                         if (entity != null)                         {                             inputstream inputstream = entity.getcontent();                             htmlcontent = converttostring(inputstream);                         }                        }                  }                 catch (exception e) {}                      return true;              } 


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -