Android Question Inline Java Error - Third Party Cookies

DawningTruth

Active Member
Licensed User
With reference to this thread on how to add 3rd Party Cookies to your Webviews:

https://www.b4x.com/android/forum/threads/lib-cookiemanager.22968/page-2#post-382194

I have copied the following code into my Project:

B4X:
'Third Party Cookie Management
#If JAVA
import android.webkit.CookieManager;
import android.webkit.WebView;

public boolean GetAcceptThirdPartyCookies(WebView webview){
    return CookieManager.getInstance().getAcceptThirdPartyCookies(WebView webview);
}

public void SetAcceptThirdPartyCookies(WebView webview, boolean accept){
    CookieManager.getInstance().setAcceptThirdPartyCookies(WebView webview, boolean accept);
}
#End If
I have copied the code in to various locations in my project such as: Top of Main, Top of MyActivity and inside MyActivity

I keep getting the following error when I try to compile my project:

javac 1.8.0_131
src\b4a\example\main.java:905: error: ')' expected
return CookieManager.getInstance().getAcceptThirdPartyCookies(WebView webview);
^
1 error
 

Erel

Administrator
Staff member
Licensed User
I have copied the code in to various locations in my project such as: Top of Main, Top of MyActivity and inside MyActivity
The position doesn't matter.

There are several mistakes in this code, however there is no such method named getAcceptThirdPartyCookies: https://developer.android.com/refer...PartyCookies(android.webkit.WebView, boolean)

B4X:
#If JAVA
import android.webkit.CookieManager;
import android.webkit.WebView;

public void SetAcceptThirdPartyCookies(WebView webview, boolean accept){
    CookieManager.getInstance().setAcceptThirdPartyCookies(webview, accept);
}
#End If
 

DawningTruth

Active Member
Licensed User
The position doesn't matter.

There are several mistakes in this code, however there is no such method named getAcceptThirdPartyCookies: https://developer.android.com/reference/android/webkit/CookieManager.html#setAcceptThirdPartyCookies(android.webkit.WebView, boolean)

B4X:
#If JAVA
import android.webkit.CookieManager;
import android.webkit.WebView;

public void SetAcceptThirdPartyCookies(WebView webview, boolean accept){
    CookieManager.getInstance().setAcceptThirdPartyCookies(webview, accept);
}
#End If
Thx Erel. Working now.
 
Top