Android Question Webview PageFinished URL Issue

Juzer Hussain

Active Member
Licensed User
Longtime User
Hi,

I am pasing control to CheckoutPage in Webview.After transactions It is redirecting to my website.The page is showing correct but the URL is wrong.
Can someone pls give some clue.

Thanks
Juzer
 

drgottjr

Expert
Licensed User
Longtime User
you need to give us some clue first: what is CheckoutPage? what transactions? what do you mean by "redirect" (with a 302 header)? if the url is wrong, how can the page show correctly? and where is pagefinished? you refer to it in the title of your thread, but then there is no mention of what the problem with it is. (pagefinished does not necessarily show every page; you should read google's documention.)

in any case, we really have no information from you.:confused:
 
Last edited:
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
Hi drgottjr,
I am using a webview to show a webpage. It is properly showing the page. In pageFinished event the URL is coming correctly. User fills up the form in the webpage and he is redirected to my website.The URL of my website must show in PageFinished event. My website is loading but the URL is not coming in PageFinished. This is probably because there are 2 redirections successively.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
it's better to show the code in your pagefinished sub
than to describe what is happening.

i'm troubled by your use of "redirection". it sounds like
you are simply loading another url when pagefinished
fires. this is not redirection. redirection has a very
specific meaning, and it comes from a server.

i want to do a test first, but i believe pagefinished is not
going to fire if i understand your case. if this is true (i will
let you know), then you need another way to determine
which url is finishing. i believe this can be done with
javascript injection (using webviewextras). although
pagefinished may not fire, the webpage itself knows
when it has loaded and can advise your b4a app with
a different event. obviously, it will take a little time to
put an example together for you (unless you already
know what i'm talking about).
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
i did my tests.

with an actual redirection, pagefinished will not fire.
i don't know if this is what you are doing.

with javascript (and webviewextras) i am able to raise
an event similar to pagefinished from within the page
that does the redirection (before it does
the redirection). so even though pagefinished does not
fire, my event is raised in b4a. since i don't know exactly
what you are doing, i don't know if this is of use to you.

since i still do not understand fully your app's flow and
exactly how you make it happen, i probably will be of no
help to you. i'm sorry.
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
Thank You drgottjr,

" with javascript (and webviewextras) i am able to raise
an event similar to pagefinished from within the page
that does the redirection (before.........."

Above is what exactly i am trying to achieve. I will try to use WebExtras.
Its almost done.


I am trying to integrate Payment Gateway. As per their requirement I am loading a URL.
My code is very simple as below. Calling PP_LoadPG in activity create and looking for success in pagefinished.

B4X:
Sub PP_LoadPG
    Dim strParams As String
    Dim stxnid,samount,sproductinfo,surl As String
   
    stxnid=sTransID
    samount=sPrice
    sproductinfo=sPInfo
   
    strParams="TID="&stxnid & "&" & "Amount=" &samount& "&" & "ProdInfo="&sproductinfo& "&" & "pCategoryID="&sCategoryId& "&" & "pMemberID="&sMemberId& "&" & "pUserID="&sUserID& "&" & "pFileName="&sFileName
    surl="http://xyz.co.in/xxx.aspx?"&strParams
   
    wv.LoadUrl(surl)
End Sub

Sub WV_PageFinished (Url As String)
Dim str As String =Url
    If str.Contains("success") Then
        ToastMessageShow("Done",True)
    End If
End Sub

Thanks Once Again.
 
Last edited:
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
thanks for the code snippet. things are becoming
clearer.

unless you're extending webview yourself, you
have to use webviewextras (or some other similar
library) to inject javascript. i can't imagine what you
were doing before.

your pagefinished sub is wrong.
1) you absolutely need log entries. don't use toast.
2) it's unlikely url is going to contain "success" (and you don't need to re-assign url).
i'm not sure what you think pagefinished is supposed to return, but "success" is not it.
3) you need an "else" clause. as it stands now, you have no way of knowing whether
or not pagefinished even fires (it does. you simply never ask it what it returned.)

B4X:
    If url.Contains("success") Then
        log("Done")
    else
        log("i didn't get success, but i did get: " & url)
    End If
i think you'll be surprised. (or maybe i will :). let's see.)
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
I am checking for "success" because final page loads with parameters in URL. One of them is status="success".
As I said earlier page is loading correctly so i check for success in URL in PageFinish.

After adding WebExtras library now i got the log saying your connection is not secure(my page is http://...) It needs a secure connection(https://) .

Mixed Content: The page at
'https://www.payumoney.com/sandbox/payment/postBackParam.do'
was loaded over a secure connection,
but contains a form that targets an insecure endpoint
'http://www.xyz.co.in/frmSuccess.aspx'.
This endpoint should be made available over a secure connection.
in https://www.payumoney.com/sandbox/payment/postBackParam.do (Line: 98)

This is the real issue.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
you need to use one of these:
B4X:
Add this line to your Manifest:
SetApplicationAttribute(android:usesCleartextTraffic, "true")

OR:
CreateResourceFromFile(Macro, Core.NetworkClearText)

but if you're listing your app on play, you'll need to specifically list that 'http://www.xyz.co.in/frmSuccess.aspx' domain in a configuration file, otherwise google won't let you list the app.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Best is to add a trusted SSL-Certificate to www.xyz.co.in ;-)
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
you need to use one of these:
B4X:
Add this line to your Manifest:
SetApplicationAttribute(android:usesCleartextTraffic, "true")

OR:
CreateResourceFromFile(Macro, Core.NetworkClearText)

but if you're listing your app on play, you'll need to specifically list that 'http://www.xyz.co.in/frmSuccess.aspx' domain in a configuration file, otherwise google won't let you list the app.
Yes drgottjr, The first line is there in the manifest. I added below line too.
B4X:
AddPermission(android.permission.INTERNET)
 
Upvote 0
Top