android打开浏览器
① Android从浏览器中打开本地应用
开发中遇到的一些问题特此记录:
1、应用场景一 在浏览器中要求直接打开到安装的应用中
需要在该应用的启动Activity 清单文件中进行配置
<Intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="com..test"
android:scheme="text"/>
</Intent-filter>
此处对应的data数据 跟服务器人员进行交互的时候为:text://com..test
2、中前应用场景二 在浏览器中进行打开 并且要求打开指定的具体的页面
首先得在清单文件中进行上面一样的配置 接着和从其他跳转的activity中获取的一样 ,通过intent来进行数据的获取
if(intent !=null) {
Uri uri = intent.getData();
if(uri !=null) {
String host = uri.getHost();
帆扒 LogUtil.d(TAG,host);
String data = uri.getQueryParameter("code");
try{
jumpData= URLDecoder.decode(data,"UTF-8");
LogUtil.d(TAG,jumpData);
}catch(UnsupportedEncodingException e) {
e.printStackTrace();
卖轿清 }
}
}
这样获取到的数据就是需要的数据 所要跳转的具体信息具体跳转类型都会获取到,然后在跟以前一样进行跳转就可以了。
② 如何在Android中调用浏览器打开网页
android打开系统默认的软件,通常使用的是inent意图这个类,如下打开浏览器: Intent
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// get the view web intent
Intent intent = this.getViewWebIntent();
this.(intent);
// set the className to use the specific browser to open the webpage.
intent.setClassName("com.tencent.mtt", "com.tencent.mtt.MainActivity");
startActivity(intent);
}
/*
*get the desired view web intent
*/
private Intent getViewWebIntent() {
Intent viewWebIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("http://www.2cto.com");
viewWebIntent.setData(uri);
return viewWebIntent;
}
里面可以填上任意的url,也可以利用inent发送信息、拨打电话,记日历
③ Android程序中怎么启动浏览器
一、启动android默认浏览器
在Android程序中我们可以通过发送隐式Intent来启动系统默认的浏览器巧猛。如果手机本身安装了多个浏览器而又没有设置默认浏览器的话,系统将让用户选择使用哪个浏览器来打开连接。关于Intent的更多内容请参考《孝则桥常用Intent》
示例1
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://www.163.com");
intent.setData(content_url);
startActivity(intent);
这样子,android就可以调用起手机默认的浏览器访问。
二、启动指定浏览器
在Android程序中我们可以通过发送显式Intent来启动指定的浏览器。
启动Android原生浏览器
示例2
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://www.163.com");
intent.setData(content_url);
intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
startActivity(intent);
只要修改以intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
中相应的应用程序packagename 和要启动的activity即可启动其他浏览器来
uc浏览器":"com.uc.browser",
"com.uc.browser.ActivityUpdate“
opera浏览器:"com.opera.mini.android"盯尘, "com.opera.mini.android.Browser"
qq浏览器:"com.tencent.mtt",
"com.tencent.mtt.MainActivity"
④ Android开发:调起手机浏览器
一、调起手机御拆拦默认浏览器
这里以调起 网络网页 为例。
二、指定相应的浏览器访问
调御圆起浏览器前需要判断该App是否已经安装在手机上,镇胡否则会使程序崩溃哦~可参考 Android开发:检测手机上是否安装该App
三、如果你从事Flutter开发,你应该还需要 iOS开发:调起Safari浏览器打开Url(对中文等特殊字符进行处理) 的知识
⑤ 如何在Android中调用浏览器打开网页
在安卓代码中我们有时需要调用浏览器来打开相应的网页,此时可以有以下几种实现方式:
一:
调用默认浏览器
Intent intent = new Intent(); //Intent
intent = new Intent(Intent.ACTION_VIEW,uri);
intent.setAction("android.intent.action.VIEW"); Uri content_url = Uri.parse("此处填链接"); intent.setData(content_url); startActivity(intent);
其他浏览器
Intent intent = new Intent(); //Intent
intent = new Intent(Intent.ACTION_VIEW,uri); intent.setAction("android.intent.action.VIEW"); Uri content_url = Uri.parse("此处填链接"); intent.setData(content_url); intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
startActivity(intent);
uc浏览器":"com.uc.browser", "com.uc.browser.ActivityUpdate“opera:"com.opera.mini.android", "com.opera.mini.android.Browser"qq浏览器:"com.tencent.mtt", "com.tencent.mtt.MainActivity"
二:
1、自定义一个简单的WebView浏览器,设置下面属性:
mWebView = (ProgressWebView) findViewById(R.id.baseweb_webview); mWebView.getSettings().setjavaScriptEnabled(true); mWebView.setWebViewClient(new WebViewClient());
2、指定需要打开的额网页,在自定义的WebViewActivity中打开,如:
WebView myWebView = (WebView) findViewById(R.id.webview); myWebView.loadUrl("http://www.hao123.com");
3、还可以查看相关的自定义WebView简单浏览器的Demo,《WebView控件实现的简单浏览器效果》,以及对应的TeachCourse介绍怎么使用
⑥ 如何在Android中调用浏览器打开网页
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
webView = (WebView) findViewById(R.id.webview);
// 设置支持javascript
webView.getSettings().setJavaScriptEnabled(true);
// 启动缓存
webView.getSettings().setAppCacheEnabled(true);
// 设置缓存模式
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
// 加载网页
webView.loadUrl("
<a href="http://..com/question/1797038222865379867.html?entry=qb_ihome_tag" target="_blank">http://..com/question/1797038222865379867.html?entry=qb_ihome_tag</a>
");
// 在当前的浏览器中响应
webView.setWebViewClient(new WebViewClient());//
需要添加网络<a href="https://www..com/s?wd=%E8%AE%BF%E9%97%AE%E6%9D%83%E9%99%90&tn=44039180_cpr&fenlei=-hPEUiqkIyN1IA-EUBtznWmvrHn3n10zn1csPjcvP1f3" target="_blank" class="-highlight">访问权限</a>
⑦ 安卓打开浏览器提示输入指令解锁功能
关闭方法如下:
1、在手机桌面上找到浏览器并打开。
2、在打开的浏览器收藏夹页面。我们点击手机左下角的编辑并枯按钮。
3、在弹出的的诸多菜单中,选择仿数点击的绝大洞是:设置。
4、找到高级这一项,点击进入。
5、把里面的几项默认开启的服务,全部关掉即可。