Is android webview able to display mp4 video with video tag?
In my application, my webview need to display video in . But, my webview is displays only blackscreen(audio is working fine).
I`m working in Android API Level 29.
This is my code about settings of webview
mWebSettings = mWebView.getSettings();
mWebSettings.setJavaScriptEnabled(true);
mWebSettings.setSupportMultipleWindows(true);
mWebSettings.setJavaScriptCanOpenWindowsAutomatically(true);
mWebSettings.setLoadWithOverviewMode(true);
mWebSettings.setUseWideViewPort(true);
mWebSettings.setSupportZoom(true);
mWebSettings.setBuiltInZoomControls(true);
mWebSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
mWebSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebSettings.setDomStorageEnabled(true);
mWebSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
mWebSettings.setMediaPlaybackRequiresUserGesture(false);
mWebSettings.setPluginState(WebSettings.PluginState.ON);
mWebSettings.setAllowUniversalAccessFromFileURLs(true);
mWebSettings.setAllowFileAccessFromFileURLs(true);
mWebSettings.setAllowFileAccess(true);
mWebSettings.setUserAgentString("Mozilla/5.0 (Linux; Android 10; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.185 Mobile Safari/537.36");
mWebView.setBackgroundColor(0x00000000);
mWebView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
mWebView.setWebViewClient(new WebViewClient(){
#Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.loadUrl(request.getUrl().toString());
}
return super.shouldOverrideUrlLoading(view, request);
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
#SuppressLint("SetJavaScriptEnabled")
#Override
public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
// Dialog Create Code
WebView newWebView = new WebView(MainActivity.this);
WebSettings webSettings = newWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
newWebView.setVisibility(View.GONE);
final Dialog dialog = new Dialog(MainActivity.this);
dialog.setContentView(newWebView);
ViewGroup.LayoutParams params = dialog.getWindow().getAttributes();
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
dialog.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
//dialog.show();
newWebView.setWebChromeClient(new WebChromeClient() {
#Override
public void onCloseWindow(WebView window) {
dialog.dismiss();
}
});
// WebView Popup에서 내용이 안보이고 빈 화면만 보여 아래 코드 추가
newWebView.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return false;
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mWebView.loadUrl(view.getUrl());
}
});
((WebView.WebViewTransport) resultMsg.obj).setWebView(newWebView);
resultMsg.sendToTarget();
//Log.d(MainURL,newWebView.getUrl());
return true;
}
#SuppressLint("SetJavaScriptEnabled")
#Override
public void onCloseWindow(WebView window) {
super.onCloseWindow(window);
window.goBack();
}
});
And I use mWebView.loadUrl(url) to load my url.
mWebView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
This line is the cause of your problem. Video playback will not work when layer type is software. So change it either to LAYER_TYPE_NONE or LAYER_TYPE_HARDWARE like:
mWebView.setLayerType(WebView.LAYER_TYPE_HARDWARE , null);
or
mWebView.setLayerType(WebView.LAYER_TYPE_NONE, null);
Quick tip: Search more on internet regarding differences between various layer types and their performance and other aspects and then only use them wisely.
Related
I need to load a PDF file within my webview on a button click within it. I have used google docs URL for loading the same. It works perfectly in S8 edge(v9.0) but it's not working in S6 edge(v6.0.1). It is not calling the shouldOverrideUrlLoading method even. Not able to understand what is the exact reason for it.
My code:
private final String googleDocs = "http://docs.google.com/gview?embedded=true&url=";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
webView.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
if (request.getUrl().toString().endsWith("pdf")) {
String pdfUrl = googleDocs + request.getUrl().toString();
view.loadUrl(pdfUrl);
} else {
view.loadUrl(request.getUrl().toString());
}
return true;
}
});
WebSettings webSettings = binding.webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.loadUrl(url);
}
I am developing an android application. It is a WebView for my website. The website contains a popup button, on clicking it, a new window will open and display the content. The link can be from external site. However when I implemented this, the new tab is opening and just after that it popsup to open browser inspite of opening it in webview. I tried with same website link also. For both case it popsup browser. Please help me with a working code to open a new tab and close it programatically. Here is my code:
public class MainActivity extends Activity {
private WebView webView;
private myWebChromeClient mWebChromeClient;
private myWebViewClient mWebViewClient;
/**
* Called when the activity is first created.
*/
#Override
public void onCreate(Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView);
mWebViewClient = new myWebViewClient();
webView.setWebViewClient(mWebViewClient);
WebSettings webSettings = webView.getSettings();
mWebChromeClient = new myWebChromeClient();
webView.setWebChromeClient(mWebChromeClient);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setSupportMultipleWindows(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
webView.getSettings().setAppCacheEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
String aapp = "Mozilla/5.0 (Linux; Android 6.0.1; Redmi Note 3 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.98 Mobile Safari/537.36";
webSettings.setUserAgentString(aapp);
webView.loadUrl("http://website/test.php");
}
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (webView.canGoBack()) {
webView.goBack();
finish();
return true;
}
}
return super.onKeyDown(keyCode, event);
}
class myWebChromeClient extends WebChromeClient {
#Override
public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
WebView newWebView = new WebView(MainActivity.this);
WebSettings webSettings = newWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
String app = "Mozilla/5.0 (Linux; Android 6.0.1; Redmi Note 3 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.98 Mobile Safari/537.36";
webSettings.setUserAgentString(app);
// Other configuration comes here, such as setting the WebViewClient
final Dialog dialog = new Dialog(MainActivity.this);
dialog.setContentView(newWebView);
dialog.show();
newWebView.setWebChromeClient(new WebChromeClient() {
#Override
public void onCloseWindow(WebView window) {
dialog.dismiss();
}
});
((WebView.WebViewTransport)resultMsg.obj).setWebView(newWebView);
resultMsg.sendToTarget();
return true;
}
}
class myWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
#Override
public void onPageFinished(WebView webView, String url) {
String webUrl = webView.getUrl();
System.out.println(webUrl);
super.onPageFinished(webView, url);
}
}
}
When a link is touched inside a webpage then depending on a webpage implementation there are two possible scenarios:
1) The link will be opened in the same window.
2) The link will be opened in new window.
For 1st scenario using below code:
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
Overiding shouldOverrideUrlLoading inside WebViewClient implementation will open link in same window.
For 2nd case, where webpage is requesting a url to be open in new window. For this case we need this:
webView.getSettings().setSupportMultipleWindows(true);
and then adding a new web chrome client to webview to get the event when a new window is requested by webpage
webView.setWebChromeClient(new WebChromeClient() {
#Override
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, Message resultMsg) {
WebView newWebView = new WebView(WebpageActivity.this);
newWebView.getSettings().setJavaScriptEnabled(true);
newWebView.getSettings().setSupportZoom(true);
newWebView.getSettings().setBuiltInZoomControls(true);
newWebView.getSettings().setPluginState(PluginState.ON);
newWebView.getSettings().setSupportMultipleWindows(true);
view.addView(newWebView);
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(newWebView);
resultMsg.sendToTarget();
newWebView.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
return true;
}
}
});
Happy to help.
guys! I have problem to load html page with android-webview. I need to load the url with my webview but not with the mobile system broswer or other broswer, so I have to apply the method setWebViewClient() to my webview but not WebChromeClient(). However, there's load nothing but blank page when applied the setWebViewClient(), and works fine with the later method. I don't know where's problem, here is the code:
.xml :
<WebView android:id="#+id/webview"
android:layout_marginTop="50dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
.java :
WebView webView = (WebView)findViewById(R.id.webView);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= 19) {
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
}
private String loadUrl = "http://www.baidu.com";
webView.loadUrl(loadUrl);
webView.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
#Override
public void onLoadResource(WebView view, String url) {
view.loadUrl(url);
super.onLoadResource(view, url);
}
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
view.loadUrl(url);
super.onPageStarted(view, url, favicon);
}
});
/*
webView.setWebChromeClient(new WebChromeClient() {
#Override
public void onProgressChanged(WebView view, int newProgress) {
Log.v(Log_Tag, String.valueOf(newProgress));
}
});
*/
Just put this code in your activity
private String loadUrl = "https://www.google.com";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView mWebView = (WebView) findViewById(R.id.webView);
WebSettings mWebSettings = mWebView.getSettings();
mWebSettings.setJavaScriptEnabled(true);
WebViewClient mWebViewClient = new WebViewClient();
mWebView.setWebViewClient(mWebViewClient);
mWebView.loadUrl(loadUrl);
}
You shouldn't override methods in WebViewClient class if you don't want to change their behavior or add some functionality. And don't forget to add permission Internet to your manifest file. WebView will not work without it.
Thanks #Mike M. again. The method shouldOverrideUrlLoading() should return false if you want to loading the url with your webView but not with the mobile system default browser or other Third-Party browsers. And, if you want to deal some javascript actions of the webpage with your webView, you're suggested to apply the WebChromClient to your webView.
Here is the good example:
WebView webView = (WebView)findViewById(R.id.webView);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
//load the page with cache
if (Build.VERSION.SDK_INT >= 19) {
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
}
webView.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//return true load with system-default-browser or other browsers, false with your webView
return false;
}
#Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
});
webView.setWebChromeClient(new WebChromeClient() {
#Override
public void onProgressChanged(WebView view, int newProgress) {
Log.v(Log_Tag, String.valueOf(newProgress));
//put your code here if your want to show the progress with progressbar
}
});
private String loadUrl = "http://www.baidu.com";
webView.loadUrl(loadUrl);
public class MainActivity extends AppCompatActivity {
WebView webView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://www.w3schools.com/");
emphasized text
I'm loading a webpage in a WebView. On clicking login through Facebook, I'm getting blank white screen. URL which is getting called is something like this: https://m.facebook.com/dialog/oauth?access_token=...
Here's my piece of code:
onCreate():
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
WebSettings webSettings = wvMain.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
//webSettings.setSupportMultipleWindows(true);
wvMain.setWebChromeClient(new UriChromeClient());
wvMain.setWebViewClient(new UriWebViewClient());
wvMain.loadUrl(myUrl);
UriWebViewClient
private class UriWebViewClient extends WebViewClient {
#Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
wvMain.loadUrl(lastUrl);
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
lastUrl = url;
}
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler,
SslError error) {
super.onReceivedSslError(view, handler, error);
}
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
try {
if (url.startsWith("http:") || url.startsWith("https:")) {
return false;
}
else if (url.startsWith("tel:")) {
//do something
return true;
} else if (url.startsWith("mailto:")) {
//do something
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
}
UriChromeClient
class UriChromeClient extends WebChromeClient {
#Override
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, Message resultMsg) {
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(wvMain);
resultMsg.sendToTarget();
return true;
}
#Override
public void onCloseWindow(WebView window) {
}
}
Is I set webSettings.setSupportMultipleWindows(true); in onCreate(), app crashes with following exception: IllegalArgumentException: Parent WebView cannot host it's own popup window. Please use WebSettings.setSupportMultipleWindows(false)
Any help appreciated. I'm stuck on this from many days.
EDIT:
Based on linked question in comment, I changed my onCreateWindow as follows:
class UriChromeClient extends WebChromeClient {
#Override
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, Message resultMsg) {
WebView wvMain = new WebView(mContext);
wvMain.setVerticalScrollBarEnabled(false);
wvMain.setHorizontalScrollBarEnabled(false);
wvMain.setWebViewClient(new UriWebViewClient());
WebSettings webSettings = wvMain.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setSupportMultipleWindows(true);
wvMain.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
mContainer.addView(wvMain);
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(wvMain);
resultMsg.sendToTarget();
return true;
}
}
Now app doesn't crash, but same white/blank screen issue is there.
by changing onCreateWindow to below, I finally got login screen:
#Override
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, Message resultMsg) {
wvMain.setVisibility(View.GONE);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
WebView wvNew = new WebView(mContext);
wvNew.setVerticalScrollBarEnabled(false);
wvNew.setHorizontalScrollBarEnabled(false);
wvNew.setWebViewClient(new UriWebViewClient());
WebSettings webSettings = wvNew.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setSupportMultipleWindows(true);
wvNew.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
mContainer.addView(wvNew);
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(wvNew);
resultMsg.sendToTarget();
return true;
}
But after successful login, I'm getting a blank screen but that's story for another day.
I'm trying to use a facebook login button that uses JS Facebook SDK on Android Webview. When I click it open a new page and redirects to https://www.facebook.com/dialog/oauth... which is a blank page with a javascript code. And the webview stays here.
I'm using:
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setAppCacheEnabled(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
Thank you!
You need to add logic to redirect back to the original url of your website.
In order to do this, you need to first create a new java class that extends the WebViewClient class and overrides the onPageFinished method like this:
public class CustomWebViewClient extends WebViewClient
{
#Override
public void onPageFinished(WebView view, String url) {
//https://www.facebook.com/dialog/permissions.request
//actually works for me, but I put the URL you say is coming up
//blank in there instead, whatever works for you:
if(url.startsWith("https://www.facebook.com/dialog/oauth")){
String redirectUrl = "http://www.mydomain.com/MyApp/";
view.loadUrl(redirectUrl);
return;
}
super.onPageFinished(view, url);
}
}
Second, just add it to your WebView:
webview.setWebViewClient(new CustomWebViewClient());
Once that page is finished loading, it will redirect back to your original page
I dont know what exactly i did at that time, but the problem was solved. I'll give you the code. Try finding out :)
WebView browser,mWebviewPop;
private void open(){
browser = (WebView)findViewById(R.id.webView1);
browser.getSettings().setLoadsImagesAutomatically(true);
browser.getSettings().setJavaScriptEnabled(true);
browser.getSettings().setAppCacheEnabled(true);
browser.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
browser.getSettings().setSupportMultipleWindows(true);
browser.setWebViewClient(new MyBrowser());
browser.setWebChromeClient(new MyCustomChromeClient());
mContext=this.getApplicationContext();
browser.loadUrl(target_url);
MainActivity.this.progressBar.setProgress(0);
browser.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
});
}
private class MyBrowser extends WebViewClient {
String redirectUrl = "MY URL";
private void noInternet() {
WebView webview = (WebView) findViewById(R.id.webView1);
RelativeLayout tryAgainLayout = (RelativeLayout)findViewById(R.id.tryAgainLayout);
RelativeLayout progressLayout = (RelativeLayout)findViewById(R.id.progressLayout);
tryAgainLayout.setVisibility(View.VISIBLE);
webview.setVisibility(View.GONE);
webview.destroy();
progressLayout.setVisibility(View.INVISIBLE);
}
public void visible(){
WebView webview = (WebView) findViewById(R.id.webView1);
RelativeLayout tryAgainLayout = (RelativeLayout)findViewById(R.id.tryAgainLayout);
RelativeLayout progressLayout = (RelativeLayout)findViewById(R.id.progressLayout);
tryAgainLayout.setVisibility(View.INVISIBLE);
webview.setVisibility(View.INVISIBLE);
progressLayout.setVisibility(View.VISIBLE);
}
public void unvisible(){
WebView webview = (WebView) findViewById(R.id.webView1);
RelativeLayout tryAgainLayout = (RelativeLayout)findViewById(R.id.tryAgainLayout);
RelativeLayout progressLayout = (RelativeLayout)findViewById(R.id.progressLayout);
tryAgainLayout.setVisibility(View.INVISIBLE);
webview.setVisibility(View.VISIBLE);
progressLayout.setVisibility(View.INVISIBLE);
}
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
String host = Uri.parse(url).getHost();
if (host.equals(target_url_prefix))
{
if(mWebviewPop!=null)
{
mWebviewPop.setVisibility(View.GONE);
baseLayout.removeView(mWebviewPop);
mWebviewPop=null;
}
return false;
}
if(host.equals("m.facebook.com"))
{
return false;
}
view.loadUrl(url);
return true;
}
#Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
noInternet();
}
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
visible();
}
#Override
public void onPageFinished(WebView view, String url) {
unvisible();
System.out.println("\n" +view.getUrl());
if(url.startsWith("https://m.facebook.com/v2.1/dialog/oauth")){
if(mWebviewPop!=null)
{
mWebviewPop.setVisibility(View.GONE);
baseLayout.removeView(mWebviewPop);
mWebviewPop=null;
}
view.loadUrl(redirectUrl);
return;
}
super.onPageFinished(view, url);
}
}
private class MyCustomChromeClient extends WebChromeClient
{
#Override
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, Message resultMsg) {
mWebviewPop = new WebView(mContext);
mWebviewPop.setVerticalScrollBarEnabled(false);
mWebviewPop.setHorizontalScrollBarEnabled(false);
mWebviewPop.setWebViewClient(new MyBrowser());
mWebviewPop.getSettings().setJavaScriptEnabled(true);
mWebviewPop.getSettings().setSavePassword(false);
mWebviewPop.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
baseLayout.addView(mWebviewPop);
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(mWebviewPop);
resultMsg.sendToTarget();
return true;
}
#Override
public void onCloseWindow(WebView window) {
}
#Override
public void onProgressChanged(WebView view, int newProgress) {
MainActivity.this.setValue(newProgress);
super.onProgressChanged(view, newProgress);
}
}
OK so from what I can tell, what's happening here is that there are two "ways" for oauth to work, either it will call back "to aparent page" (like popup "log me in" that disappears), or it can redirect you to a login page, then to some other url (non popup style), after success or failure (kind of a chain forward). Unfortunately it appears WebView is not well suited for the "callback to the parent page" style, so you have to do some shenanigans like have a second WebView (jincy's answer here, or see also this).