Accepting all cookies in webview | Android

Viewed 26

I have been trying to find a solution so long to my problem. for some reason, my code doesn't automatically accepts cookies in the webview. Maybe someone who understands better than me could understand the problem:

public class HomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        setTitle("Title");

        WebView wb = (WebView) findViewById(R.id.Login);
        if (android.os.Build.VERSION.SDK_INT >= 21) {
            CookieManager.getInstance().setAcceptThirdPartyCookies(wb, true);
        }else {
            CookieManager.getInstance().setAcceptCookie(true);
        }
        wb.setWebViewClient(new WebViewClient());
        wb.loadUrl("PRIVATELINK");
    }
}
0 Answers
Related