android启动浏览器
㈠ 安卓开发怎么在APP内部调用手机系统浏览器打开指定html并获取HTML的数据
Android开发_如何调用 浏览器访问网页和Html文件
一、启动android默认浏览器
Intent intent= new Intent();
intent.setAction('android.intent.action.VIEW');
Uri content_url = Uri.parse('http://www.cnblogs.com');
intent.setData(content_url);
startActivity(intent);
这样子,android就可以调用起手机默认的浏览器访问。
二、指定相应的浏览器访问
1、指定android自带的浏览器访问
( “com.android.browser”:packagename ;“com.android.browser.BrowserActivity”:启动主activity)
Intent intent= new Intent();
intent.setAction('android.intent.action.VIEW');
Uri content_url = Uri.parse('http://www.cnblogs.com');
intent.setData(content_url);
intent.setClassName('com.android.browser','com.android.browser.BrowserActivity');
startActivity(intent);
2、启动其他浏览器(当然该浏览器必须安装在机器上)
只要修改以下相应的packagename 和 主启动activity即可调用其他浏览器
intent.setClassName('com.android.browser','com.android.browser.BrowserActivity');
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'
三、打开本地html文件
打开本地的html文件的时候,一定要指定某个浏览器,而不能采用方式一来浏览,具体示例代码如下
Intent intent= new Intent();
intent.setAction('android.intent.action.VIEW');
Uri content_url = Uri.parse('content://com.android.htmlfileprovider/sdcard/help.html');
intent.setData(content_url);
intent.setClassName('com.android.browser','com.android.browser.BrowserActivity');
startActivity(intent);
关键点是调用了”content“这个filter。
以前有在win32编程的朋友,可能会觉得用这种形式”file://sccard/help.html“是否可以,可以很肯定的跟你说,默认的浏览器设置是没有对”file“这个进行解析的,如果要让你的默认android浏览器有这个功能需要自己到android源码修改manifest.xml文件,然后自己编译浏览器代码生成相应的apk包来重新在机器上安装。
大体的步骤如下:
1、打开 packages/apps/Browser/AndroidManifest.xml文件把加到相应的后面就可以了
2、重新编译打包,安装,这样子,新的浏览器就支持”file“这个形式了
有兴趣的可以去试试。
㈡ android studio怎么调用手机内部浏览器
、启动android默认浏览器
Intent intent= new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://www.cnblogs.com");
intent.setData(content_url);
startActivity(intent);
这样子,android就可以调用起手机默认的浏览器访问。
㈢ 安卓手机如何取消默认操作点击链接总是起动自带浏览器。
关于安卓手机取消链接默认自带浏览器打开的具体操作如下:
在安卓系统先找到应用程序管理,就是那个删除程序的那个列表里找到浏览器和默认的;
然后点开,里面有清楚数据,点一下就好,下次点关于浏览器的东西就会有一个框上面选择默认浏览器,先勾选下面的记住然后再点浏览器。如下图所示:
㈣ android 怎么打开微信浏览器
首先打开google浏览器,同时按下 F12 键 模拟手机环境
点击页面右上角的 settings 按钮
出先设置页面 先点击 Devics 让后点击 底部添加按钮
出
现添加信息的页面 这里如图添加上边可以随意填写 比如名称 大小分辨率 最重要的是在 User Agent String
框里面填写一下信息 “Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660
Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0
Mobile Safari/533.1 MicroMessenger/4.5.255” 最后点击 add device 按钮
添加最后现在device的选择框中
最后在浏览器中添加你要打开的网址, 然后选择刚才添加的 test
㈤ android 怎么让系统浏览器打开指定链接
android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据 方法/步骤 为了实现这个功能可折腾了我好久,先上一份代码,经楼主验证是绝对可以用的而且也比较清晰的代码!(ps:还是先剧透下吧,第三方大部分浏览器无法成功。) 点击浏览器中的URL链接,启动特定的App。 首先做成HTML的页面,页面内容格式如下: <a href="[scheme]://[host]/[path]?[query]">启动应用程序</a> 这一句就可以了。 各个项目含义如下所示: scheme:判别启动的App。 ※详细后述 host:适当记述 path:传值时必须的key ※没有也可以 query:获取值的Key和Value ※没有也可以 作为测试好好写了一下,如下: <a href="myapp://jp.app/openwith?name=zhangsan&age=26">启动应用程序</a> 接下来是Android端。 首先在AndroidManifest.xml的MAIN Activity下追加以下内容。(启动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:scheme="myapp" android:host="jp.app" android:pathPrefix="/openwith"/> </intent-filter> HTML记述的内容加入<data …/>。 其中必须的内容仅scheme,没有其他内容app也能启动。 ※注意事项:intent-filter的内容【android.intent.action.MAIN】和 【android.intent.category.LAUNCHER】这2个,不能与这次追加的内容混合。 所以,如果加入了同一个Activity,请按以下这样做,否则会导致应用图标在桌面消失等问题。 复制代码 <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <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:scheme="myapp" android:host="jp.app" android:pathPrefix="/openwith"/> </intent-filter> 复制代码 这样的话,没有问题。 接下来在Activity中需要取值的地方添加以下代码,我是直接写在OnCreate函数里的: Intent i_getvalue = getIntent(); String action = i_getvalue.getAction(); if(Intent.ACTION_VIEW.equals(action)){ Uri uri = i_getvalue.getData(); if(uri != null){ String name = uri.getQueryParameter("name"); String age= uri.getQueryParameter("age"); } } 这样就能获取到URL传递过来的值了。 ——————————————————————————————————我是分割线———————————————————————————————————— 代码完了,是不是很惊奇的发现用浏览器输入 myapp://jp.app/openwith?name=zhangsan&age=26 是不是404,打不开? 楼主你这不是骗人么!楼主你个混蛋啊。 客官,稍安勿躁啊,你看看你用的浏览器是什么?UC,猎豹,欧朋?放弃吧,试试系统自带浏览器或者谷歌浏览器吧。肯定能成功的,不能成功的话再来坑我。哈哈。 ——————————————————————————————————我是分割线———————————————————————————————————— 突然觉得好悲哀,好不容易get了这个技能,却不能被第三方浏览器使用。在这个android浏览器大部分被第三方占据着的时代不得不说是个悲剧啊。 接下来还是说说为什么第三方浏览器不能成功吧。首先,我发现的是UC浏览器,如果你使用了自己的scheme,而不是http的话,uc会默认在你的scheme前面添加。这太坑爹了。其他浏览器没看是不是同样的情况。发现这个问题后我就试着把自己的scheme换成http。然后满怀期待的又跑了一遍,结果还是坑爹了。所以我想会不会是第三方浏览器对url做了处理。到这里,我也无可奈何了。我测试了UC,猎豹,欧朋,这3个都不支持。系统自带的和谷歌浏览器是支持的。 最后再补充个线索吧,在浏览器里搜索网络应用。进了他们的页面后,他们是可以实现在各种浏览器启动已经安装好的本地app的。看到这个后我就看了下他们页面的源码。 在这里他们页面添加了个data-sentintent的标签,看到这里,应该能确定第三方浏览器应该是默认都不支持发intent的,只能自己起一个。根据前端说,这个标签应该是自定义的。我们前端看源码的时候发现是这样的 所以最后的结果应该是网络这边是起了个端口,然后在应用里启用了一个服务,来监听这个端口,来获取这个intent。大概就这个思路了。不过楼主没有实际去操作。项目时间紧,太麻烦了。
㈥ Android怎么更改默认浏览器什么的.....
Android系统手机上清除默认设置的步骤:
1、进入手机【设置】
2、选择【应用】
3、点击进入某个应用,然后找到【默认启动】那个设置,点击【清除默认设置】。
接着你可以把想要的软件设为默认使用软件。
同时,再打开一个外部链接或视频的时候,没有设置默认软件的话会弹出窗口让你选择使用何种方式打开,此时你也可以设置:比如从微信朋友圈选择在浏览器打开观看时,会弹出一个(如图)此时你也可以做修改,当然,是从你已经安装的软件是选择默认软件
㈦ android webview 默认浏览器打开
dialog.setContentView(view),view可以是一个包含有WebView组件的布局,这样就可以在Dialog中显示了
启动android默认浏览器
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://www.cnblogs.com");
intent.setData(content_url);
startActivity(intent);
㈧ android下打开Web浏览器的几种常见的方法
android下打开Web浏览器的几种常见的方法如下:
一。通过意图实现浏览
//通过下述方法打开浏览器
java">privatevoidopenBrowser(){
//urlText是一个文本输入框,输入网站地址
//Uri是统一资源标识符
Uriuri=Uri.parse(urlText.getText().toString());
Intentintent=newIntent(Intent.ACTION_VIEW,uri);
startActivity(intent);
}
注意:输入URL时,不要忘记“http://”部分。
二。利用视图打开网页,是通过调用WebKit浏览器引擎提供的WebView实现的。
具体源代码如下:
<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<LinearLayoutandroid:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<EditText
android:layout_width="240dp"
android:layout_height="wrap_content"
android:id="@+id/etWebSite"
android:hint="输入网址"
android:singleLine="true"
android:layout_marginRight="5dp"
/>
<Button
android:id="@+id/searchBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="搜索"
android:layout_marginRight="5dp"
/>
</LinearLayout>
<LinearLayoutandroid:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/backBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="上一页"
android:layout_marginRight="5dp"
/>
<Button
android:id="@+id/nextBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一页"
android:layout_marginRight="5dp"
/>
</LinearLayout>
<WebViewandroid:id="@+id/webView1"android:layout_width="match_parent"
android:layout_height="match_parent"></WebView>
</LinearLayout>
/res/src/com.myandroid
packagecom.myandroid;
importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.view.View;
importandroid.webkit.URLUtil;
importandroid.webkit.WebView;
importandroid.widget.Button;
importandroid.widget.EditText;
importandroid.widget.Toast;
{
privateButtonschBtn,backBtn,nextBtn;
privateWebViewwebView;
privateEditTextmText;
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
schBtn=(Button)findViewById(R.id.searchBtn);
mText=(EditText)findViewById(R.id.etWebSite);
webView=(WebView)findViewById(R.id.webView1);
backBtn=(Button)findViewById(R.id.backBtn);
nextBtn=(Button)findViewById(R.id.nextBtn);
schBtn.setOnClickListener(newView.OnClickListener(){
publicvoidonClick(Viewv){
//TODOAuto-generatedmethodstub
//设置可以使用Javascript
webView.getSettings().setJavaScriptEnabled(true);StringstrURI=mText.getText().toString();
//检测网站的合法性
if(URLUtil.isNetworkUrl(strURI)){
webView.loadUrl(strURI);
Toast.makeText(WebViewActivity.this,strURI,Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(WebViewActivity.this,"输入非法网站 "+strURI,Toast.LENGTH_SHORT).show();
}
}
});
backBtn.setOnClickListener(newView.OnClickListener(){
publicvoidonClick(Viewv){
//TODOAuto-generatedmethodstub
if(webView.canGoBack()){
webView.goBack();
}
}
});
nextBtn.setOnClickListener(newView.OnClickListener(){
publicvoidonClick(Viewv){
//TODOAuto-generatedmethodstub
if(webView.canGoForward()){
webView.goForward();
}
}
});
}
}
同时还要在AndroidManifest.xml中添加访问因特网的权限:
<uses-permission android:name="android.permission.INTERNET"/>
㈨ android开发怎么调用浏览器打开一个链接
在安卓代码中调用浏览器来打开相应的网页,一般有以下几种方式
调用默认浏览器。
其他浏览器。
自定义一个简单的WebView浏览器。
【原理】
主要是通过代码进行调用已有或者未有的浏览器进行打开相应的网页进行浏览。
【详细实现步奏】
一.调用默认浏览器
优缺点:部分手机可能连默认的浏览器都没有。
Intentintent=newIntent();
//Intentintent=newIntent(Intent.ACTION_VIEW,uri);
intent.setAction("android.intent.action.VIEW");
Uricontent_url=Uri.parse("此处填链接");
intent.setData(content_url);
startActivity(intent);
二.其他浏览器,制定打开
缺点:必须知道打开的浏览器的包名,大部分用户可能没有安装这些浏览器
Intentintent=newIntent();
intent.setAction("android.intent.action.VIEW");
Uricontent_url=Uri.parse("此处填链接");
intent.setData(content_url);
intent.setClassName("浏览器包名","浏览器首页");
startActivity(intent);
三.自定义一个简单的WebView浏览器
优缺点:推荐使用,不必担心手机上是否有浏览器。
mWebView=(WebView)findViewById(R.id.baseweb_webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(newWebViewClient());
WebViewmyWebView=(WebView)findViewById(R.id.webview);
myWebView.loadUrl("xxx.com");
【最后】
每种方法根据个人需要进行选用,没其他特别因素推荐使用第三种方案。
㈩ 安卓如何只启动默认浏览器 但不打开url 就是打开浏览器
在apps/Browser下面,找到加载URL的地方,2.3是在BrowserActivity下面,2.3之后的我不知道了。这个默认的URL一般放在res/values/strings.xml或者方案商写死的地方,你恢复出厂设置后打开浏览器,打开的页面就是默认的URL,搜索这个URL在哪里。
查看原帖>>