[英]Is there a way to launch the personal browser from an Android For Work app by intent?
I have an Android for Work app installed and I would like to open the browser. 我已经安装了Android for Work应用程序,我想打开浏览器。 The way with the classic intents work, but opens the browser in the work space.
经典意图的工作方式,但是在工作空间中打开浏览器。
Due to some network stuff, I need the personal browser to be used. 由于网络问题,我需要使用个人浏览器。 Is there a way to tell the intent to start the personal browser instead of the work space browser?
有没有办法告诉您启动个人浏览器而不是工作空间浏览器的意图?
You can use WebView instead of other web browsers. 您可以使用WebView代替其他Web浏览器。
xml code xml代码
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
/>
java code Java代码
WebView webView = findViewById(R.id.webView);
webView.setWebViewClient(new MyBrowser());
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// progress is the percentage of website loaded
}
});
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.loadUrl("https://www.google.co.in"); //url you want to open
webView.setWebContentsDebuggingEnabled(true);
MyBrowser.java MyBrowser.java
private class MyBrowser extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
by using above code you can open brower in you app and it will not need intent. 通过使用以上代码,您可以在应用中打开浏览器,而无需使用意图。 for any query comment below.
对于以下任何查询评论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.