㈠ 如何在Android中調用瀏覽器打開網頁

1、首先建立響應方法:
link.setOnClickListener(buttonListener);
此外需要響應方法:
case R.id.imageButton1:link();break;


2、在工程適當部分添加如下代碼
//press @link button and open brower to www.yiban.cn
private void link()
// TODO Auto-generated method stub
String url = "http://www.webadress.cn"; // web address
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);


3、導入相應類:String、Content、Uri等,編譯無錯後運行測試,可以發現觸發事件發生時就可以調用手機瀏覽器打開特定網頁。

㈡ android APP 寫了一個打開指定網頁的應用 但是點任何連接都會跳轉到瀏覽器

java">.如果頁面中鏈接,如果希望點擊鏈接繼續在當前browser中響應,而不是新開Android的系統browser中響應該鏈接,必須覆蓋webview的WebViewClient對象。
mWebView.setWebViewClient(newWebViewClient(){
(WebViewview,Stringurl){
view.loadUrl(url);
returntrue;
}
});

或者直接跳轉到其它有webView的頁面載入url

㈢ 安卓怎麼用瀏覽器打開瀏覽器文件

看你用的是什麼瀏覽器,像UC,就到UCdonwload QQ就到QQBrower,其他的就是打開瀏覽器的文件夾就可以找到。

㈣ android 如何調用默認瀏覽器(webservice)打開網頁使用post的方式傳遞參數。

用HttpURLConnection對象,我們可以向網路發送請求參數. String requestUrl = "http://localhost:8080/itcast/contanctmanage.do"; Map<String, String> requestParams = new HashMap<String, String>(); requestParams.put("age", "12"); requestParams.put("name", "中國"); StringBuilder params = new StringBuilder(); for(Map.Entry<String, String> entry : requestParams.entrySet()){ params.append(entry.getKey()); params.append("="); params.append(URLEncoder.encode(entry.getValue(), "UTF-8")); params.append("&"); } if (params.length() > 0) params.deleteCharAt(params.length() - 1); byte[] data = params.toString().getBytes(); URL realUrl = new URL(requestUrl); HttpURLC...

㈤ android下打開Web瀏覽器的幾種常見的方法

android下打開Web瀏覽器的幾種常見的方法如下:

一。通過意圖實現瀏覽

//通過下述方法打開瀏覽器

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");

【最後】

每種方法根據個人需要進行選用,沒其他特別因素推薦使用第三種方案。

㈦ 如何在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瀏覽器如何打開本地html文件

android 瀏覽器
打開本地html文件的方法
有些html文件放在本地磁碟和sdcard,如何用打開這個網頁呢?
這種應用在測試時非常有用。
有2個方法:
1.使用文件管理器
如ES等,需要幸運的是你的文件管理器直接用瀏覽器打開。
2.在瀏覽器輸入地址
訪問本地磁碟和SD卡上的HTML,前部分content://com.android.htmlfileprovider是Provider的標准,後面是程序目錄。
比如sdcard的tesl.html
直接在瀏覽器里輸入content://com.android.htmlfileprovider/sdcard/test.html回車就可以看到網頁了。

在代碼
webView.loadUrl("content://com.android.htmlfileprovider/sdcard/test.html")
如果是其它程序的私有html文件,這樣做會失敗。
這是由於com.android.htmlfileprovider的許可權不夠,如果是重寫一個私有的HtmlProvider位於同一個應用中,應該能解決問題。然後就參考了原來的com.android.htmlfileprovider
源代碼,改寫了下。問題解決了,使用私有的HTMLProvider,可以輕松的訪問手機內存中,程序私有目錄下的html文件。
網上有例子,你可以搜索!

㈨ 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"