當前位置:首頁 » 安卓系統 » android啟動瀏覽器

android啟動瀏覽器

發布時間: 2022-04-22 17:48:18

㈠ 安卓開發怎麼在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就可以調用起手機默認的瀏覽器訪問。

安卓手機如何取消默認操作點擊鏈接總是起動自帶瀏覽器。

關於安卓手機取消鏈接默認自帶瀏覽器打開的具體操作如下:

  1. 安卓系統先找到應用程序管理,就是那個刪除程序的那個列表裡找到瀏覽器和默認的;

  2. 然後點開,裡面有清楚數據,點一下就好,下次點關於瀏覽器的東西就會有一個框上面選擇默認瀏覽器,先勾選下面的記住然後再點瀏覽器。如下圖所示:


㈣ 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開發怎麼調用瀏覽器打開一個鏈接

在安卓代碼中調用瀏覽器來打開相應的網頁,一般有以下幾種方式

  1. 調用默認瀏覽器。

  2. 其他瀏覽器。

  3. 自定義一個簡單的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在哪裡。
查看原帖>>

熱點內容
美嘉演算法口訣 發布:2025-05-16 06:03:15 瀏覽:952
c程序編譯連接 發布:2025-05-16 06:02:36 瀏覽:964
腳本魔獸 發布:2025-05-16 06:01:52 瀏覽:330
文件夾python 發布:2025-05-16 06:01:43 瀏覽:627
電腦我的世界伺服器游戲幣 發布:2025-05-16 05:27:25 瀏覽:488
索尼手機為什麼不能用安卓10 發布:2025-05-16 05:18:46 瀏覽:784
蔚來es6選擇哪些配置實用 發布:2025-05-16 05:18:05 瀏覽:130
小米如何掃碼wifi密碼 發布:2025-05-16 05:13:38 瀏覽:807
樓層密碼是什麼意思 發布:2025-05-16 05:13:37 瀏覽:13
創建文件夾失敗 發布:2025-05-16 05:12:59 瀏覽:397