android訪問網頁源碼
操作方法如下:
1、首先打開手機,找到並點擊進入設置,如下圖所示。
⑵ 求Android全屏載入本地網頁或全屏顯示URL網 的源碼
//用eclipse新建一個android項目然後將main里的代碼換成這個,裡面的URL要改一下,然後運行,在bin文件里就會有個.apk文件了,這個是全屏顯示網頁的!
package com.page.test;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class TestActivity extends Activity {
/** Called when the activity is first created. */
WebView webView;
WebViewClient webViewClient;
Context context;
int screenHeight;
int screenWidth;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
context = this.getApplicationContext();
webView = new WebView(context);
webView.setWebChromeClient(new WebChromeClient());
webViewClient = new WebViewClient();
webView.setWebViewClient(webViewClient);
Display display = this.getWindowManager().getDefaultDisplay();
if (display.getHeight() < display.getWidth()) {
screenHeight = display.getWidth();
screenWidth = display.getHeight();
} else {
screenWidth = display.getWidth();
screenHeight = display.getHeight();
}
webView.setLayoutParams(new ViewGroup.LayoutParams(screenWidth, screenHeight));
webView.loadUrl("連接地址");
}
}
⑶ android怎麼獲取JS執行之後的網頁源代碼
可以試用phantomjs載入網頁,執行js,然後獲取執行後的網頁代碼。
官網: http://phantomjs.org/
⑷ 如何在安卓手機查看html源代碼
網路「查看網頁源碼」,有很多支持查看網頁源碼的在線站點
⑸ 安卓如何實現獲取網頁源代碼
public class GetHtmlCodeActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textView = (TextView)this.findViewById(R.id.picture_textview);
try {
textView.setText(getPictureData("http://www..com"));
} catch (Exception e) {
Log.e("GetHtmlCodeActivity", e.toString());
Toast.makeText(GetHtmlCodeActivity.this, "網路連接失敗", 1).show();
}
}
//得到圖片的二進制數據
public String getPictureData(String path) throws Exception{
// 類 URL 代表一個統一資源定位符,它是指向互聯網「資源」的指針。
URL url = new URL("http://www..com/");
// 每個 HttpURLConnection 實例都可用於生成單個請求,
//但是其他實例可以透明地共享連接到 HTTP 伺服器的基礎網路
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//設置 URL 請求的方法
conn.setRequestMethod("GET");
//設置一個指定的超時值(以毫秒為單位),
//該值將在打開到此 URLConnection 引用的資源的通信鏈接時使用。
conn.setConnectTimeout(5 * 1000);
// conn.getInputStream()返回從此打開的連接讀取的輸入流
InputStream inStream = conn.getInputStream();// 通過輸入流獲取html數據
byte[] data = readInputStream(inStream);// 得到html的二進制數據
String html = new String(data);
return html;
}
//讀取輸入流中的數據,返回位元組數組byte[]
public byte[] readInputStream(InputStream inStream) throws Exception{
//此類實現了一個輸出流,其中的數據被寫入一個 byte 數組
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
// 位元組數組
byte[] buffer = new byte[1024];
int len = 0;
//從輸入流中讀取一定數量的位元組,並將其存儲在緩沖區數組buffer 中
while ((len = inStream.read(buffer)) != -1) {
// 將指定 byte 數組中從偏移量 off 開始的 len 個位元組寫入此輸出流
outStream.write(buffer, 0, len);
}
inStream.close();
//toByteArray()創建一個新分配的 byte 數組。
return outStream.toByteArray();
}
}
可以看一下這個自己想想哦
⑹ Android 在WebView中通過javascript獲取網頁源碼,並在TextView或者在EditText中顯示問題
webview js之間的交互,項目中馬上用到。
JS調用java代碼效果圖
index.html代碼:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd";><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" language="javascript"> var share = JSON.stringify({"title": "sinodata",
"desc": "ios",
"shareUrl": "http://www.sinodata.com.cn"
});
function sendInfoToJava(){
window.AndroidWebView.showInfoFromJs(share);
}
<!--在android代碼中調用此方法-->
function showInfoFromJava(msg){
alert("showInfoFromJava:"+msg);
} </script></head><body la><div id='b'> <input onclick="sendInfoToJava()" type="button" value="sendInfoToJava"/></div></body></html>
布局代碼:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.chenjifang.webview.MainActivity"> <Button android:id="@+id/test_btn" android:text="代碼中調用web js代碼傳遞參數" android:layout_width="match_parent" android:layout_height="wrap_content" /> <EditText android:id="@+id/test_edt" android:layout_width="match_parent" android:layout_height="wrap_content" /><WebView android:id="@+id/test_webview" android:layout_width="match_parent" android:layout_height="400dp"></WebView></LinearLayout>
java代碼:
public class MainActivity extends AppCompatActivity {private WebView mWebView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWebView = (WebView) findViewById(R.id.test_webview); //設置WebView支持JavaScript mWebView.getSettings().setJavaScriptEnabled(true); mWebView.loadUrl("file:///android_asset/index.html"); mWebView.addJavascriptInterface(new JsInterface(this), "AndroidWebView"); //添加客戶端支持 mWebView.setWebChromeClient(new WebChromeClient()); findViewById(R.id.test_btn).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
sendInfoToJs(); }
}); } private class JsInterface { private Context mContext; public JsInterface(Context context) { this.mContext = context; } //在js中調用window.AndroidWebView.showInfoFromJs(name),便會觸發此方法。 @JavascriptInterface public void showInfoFromJs(String share) {
Toast.makeText(mContext, share, Toast.LENGTH_SHORT).show(); }
} //在java中調用js代碼 public void sendInfoToJs() {
String msg = ((EditText)findViewById(R.id.test_edt)).getText().toString(); //調用js中的函數:showInfoFromJava(msg) mWebView.loadUrl("javascript:showInfoFromJava('" + msg + "')"); }
總結下,java代碼中要設置webview對javascript的支持,addJavascriptInterface(new JsInterface(this), "AndroidWebView");//這句代碼中的第二個參數是在js訪問方法的地址。
window.AndroidWebView.showInfoFromJs(share);
⑺ 游戲軟體怎麼查看源代碼
游戲都是進行過編譯,加密的無法看到源代碼。如果你想查看的游戲是開源的,可以到游戲的開源網站進行查看。
查看APP應用的源代碼的具體方法步驟如下:
1、首先在電腦內下載並安裝獲取網頁源碼app。
2、然後單擊打開網頁源碼APP並悉高在APP中的睜鏈尺輸入框內輸入想要查看的網址,再在界面內找到GO選項單並單擊。
3、單擊後等待APP最後載入3秒就可以成功的獲取APP源代碼並查看了。
Android系統源代碼多大
是指sdk的源碼喚殲,還是android操作系統的源碼,不過都有10G左右,另外sdk的源碼是用git管理的,一次下載後,用gitcheck就可以切換到各個版本。
AndroidSDK是用於開發Android上JAVA應用程序的,另外發布AndroidNDK,可以添加一些C語言寫的鏈接庫,至於Linux代碼,可以在Android源代碼中找到(SDK程序中只有編譯好的測試映像)。
應用程序開發用不到Linux代碼(搞嵌入式開發才會用到,而SDK不負責底層開發)。
⑻ 在安卓手機端查看網頁源碼的瀏覽器,請提供名字
一.IE瀏覽器。
首先打開一個網頁,點擊網頁右上方的設置及更多。
2.然後點擊F12開發人員工具。
3.然後就會彈出網頁的源文件。
二.谷歌瀏覽器。
首先打開谷歌瀏覽器,點擊右上方的三個豎點。
2.找到更多工具,並點擊開發者工具。
3.即可查看網頁源代碼。
4.一般的我們可以直接單擊滑鼠右鍵,點擊查看網頁源代碼即可,此方法比較簡單。
資料拓展:
網頁瀏覽器是個顯示網站伺服器或文件系統內的文件,並讓用戶與這些文件交互的一種應用軟體。它用來顯示在萬維網或區域網等內的文字、圖像及其他信息。這些文字或圖像,可以是連接其他網址的超鏈接,用戶可迅速及輕易地瀏覽各種信息。大部分網頁為HTML格式,有些網頁需特定瀏覽器才能正確顯示。
⑼ 有沒有可以在 iOS 和 Android 上查看網頁源碼的瀏覽器
Android
上的
Firefox
可以在地址欄里的原URL前加
view-source:
即可查看源代碼。
加裝這個插件會新開一個標簽來查看源代碼,更方便些。
View
Source
Mobile
View
Source
Mobile
::
Add-ons
for
Firefox
for
Android
另外
@Bill
Cheng
:
Android
上的
Firefox
暫時還沒有
FireBug
。