你的位置:
首页
>
IT圈
>
Android中处理apple-touch-icon详解
2024年5月22日发(作者:汝芷若)
protected String LOGTAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
te(savedInstanceState);
WebView webView = new WebView(this);
tings().setJavaScriptEnabled(true);
ViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
Finished(view, url);
final String touchIconJsCode = getTouchIconJsCode();
Log.i(LOGTAG , "onPageFinished url = " + url + ";touchIconJsCode=" + touchIconJsCode);
l("javascript:" + touchIconJsCode);
}
});
ascriptInterface(new JsObject(), "app_native");
l("192.168.1.5:8000/html/");
}
private class JsObject {
@JavascriptInterface
public void onReceivedTouchIcons(String url, String json) {
Log.i(LOGTAG, "onReceivedTouchIcons url=" + url + ";json=" + json);
}
}
private String getTouchIconJsCode() {
StringBuilder total = new StringBuilder();
InputStream inputStream = null;
BufferedReader bufferReader = null;
try {
inputStream = getAssets().open("");
bufferReader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = ne()) != null) {
(line);
}
} catch (FileNotFoundException e) {
tackTrace();
} catch (IOException e) {
tackTrace();
} finally {
if (null != inputStream) {
try {
();
} catch (IOException e) {
tackTrace();
}
}
}
return ng();
}
}
返回的JSON数据
复制代码 代码如下:
[
{
2024年5月22日发(作者:汝芷若)
protected String LOGTAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
te(savedInstanceState);
WebView webView = new WebView(this);
tings().setJavaScriptEnabled(true);
ViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
Finished(view, url);
final String touchIconJsCode = getTouchIconJsCode();
Log.i(LOGTAG , "onPageFinished url = " + url + ";touchIconJsCode=" + touchIconJsCode);
l("javascript:" + touchIconJsCode);
}
});
ascriptInterface(new JsObject(), "app_native");
l("192.168.1.5:8000/html/");
}
private class JsObject {
@JavascriptInterface
public void onReceivedTouchIcons(String url, String json) {
Log.i(LOGTAG, "onReceivedTouchIcons url=" + url + ";json=" + json);
}
}
private String getTouchIconJsCode() {
StringBuilder total = new StringBuilder();
InputStream inputStream = null;
BufferedReader bufferReader = null;
try {
inputStream = getAssets().open("");
bufferReader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = ne()) != null) {
(line);
}
} catch (FileNotFoundException e) {
tackTrace();
} catch (IOException e) {
tackTrace();
} finally {
if (null != inputStream) {
try {
();
} catch (IOException e) {
tackTrace();
}
}
}
return ng();
}
}
返回的JSON数据
复制代码 代码如下:
[
{