i am very new to android studio and i am tryin to hide the 'cookie' element of my website i am showing in webview.
Now i don't really know what i have to do right, i tryed it this way:
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
private WebView clanapp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
clanapp = (WebView) findViewById(R.id.clanapp);
clanapp.getSettings().getJavaScriptEnabled();
clanapp.setWebViewClient(new MyWebViewClient());
clanapp.loadUrl("javascript:(function() { " +
"document.getElementById('cookie').style.display='none';})()");
clanapp.loadUrl("javascript:(function() { " +
"document.getElementById('cookie').style.display='none';})()");
String ENROLLMENT_URL;
ENROLLMENT_URL = "myURL";
clanapp.loadUrl(ENROLLMENT_URL);
}
public final class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading (WebView view, String url) {
return false;
}
}
}
Kindly thank you for every helping suggestion.
Aucun commentaire:
Enregistrer un commentaire