Hi All,
Can someone help provide the equivalent B4I code to the one below
Can someone help provide the equivalent B4I code to the one below
B4X:
Private Sub InvokeLoginURL(UrlToInvoke As String, UserName As String, Password As String )
If WebView1.IsInitialized = False Then
WebView1.Initialize("WebView1")
Activity.AddView(WebView1, 0, 0%y, 100%x, 100%y)
End If
Dim NativeMe As JavaObject
NativeMe.InitializeContext
NativeMe.RunMethod("SetAcceptThirdPartyCookies", Array As Object(WebView1, True))
CookieManager1.RemoveAllCookies
CookieManager1.SetAcceptCookies(True)
Private tempPostUrl As String = UrlToInvoke
Private tempPostString As String = "User=XXX&Password=YYY".Replace("XXX",UserName).Replace("YYY",Password)
Private bytesOfPOstRequest() As Byte
bytesOfPOstRequest=tempPostString.GetBytes("UTF8")
Private jo As JavaObject = WebView1
jo.RunMethod("postUrl",Array As Object(tempPostUrl,bytesOfPOstRequest))
End Sub
Sub WebView1_PageFinished (Url As String)
Try
If CookieManager1.HasCookies Then
Log(CookieManager1.GetCookie(Url))
Else
LogColor("No cookies found", Colors.White)
End If
Catch
LogColor(LastException, Colors.Red)
End Try
End Sub
#If JAVA
import android.webkit.CookieManager;
import android.webkit.WebView;
public void SetAcceptThirdPartyCookies(WebView webview, boolean accept){
CookieManager.getInstance().setAcceptThirdPartyCookies(webview, accept);
}
#End If
Last edited: