I have a Twitter timeline in WebView that is perfectly displayed. I followed this post as a guide. I currently do not want to entertain other options such as Twitter4J, although I appreciate that this is a good alternative.
My problem is that I canโt click any links, images or interact with the timeline in any other way, except to scroll up and down. I get the following error. How to get around this?
05-29 19:09:10.887: I/chromium(13226): [INFO:CONSOLE(0)] "Refused to display 'https://mobile.twitter.com/XXXXXXXX/status/YYYYYYYYYY/photo/1' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.", source: https://twitter.com/XXXXXXXX/status/YYYYYYYYYY/photo/1 (0)
Here is my code:
// Locate the WebView in fragment_twitter.xml
WebView tweetWebView = (WebView) V.findViewById(R.id.tweetWebView);
// Settings for the WebView
tweetWebView.setBackgroundColor(0);
tweetWebView.getSettings().setJavaScriptEnabled(true);
tweetWebView.getSettings().setDomStorageEnabled(true);
// Load the WebView with the imageURL
String timelineWidget = "<a class=\"twitter-timeline\" data-dnt=\"true\" href=\"https://twitter.com/XXXXXXXX\" data-widget-id=\"SECRETNUMBER\">Tweets by @XXXXXXXX</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.async=true;js.src=p+\"://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>";
tweetWebView.loadDataWithBaseURL("https://twitter.com", timelineWidget, "text/html", "UTF-8", null);
source
share