Interaction between Web3 and local Ethereum
If you want to query the transaction records on the main network, you can use Etherscan. However, if you build your own private chain, how should you query the transaction records
the answer is that you need to listen to the logs on the chain, save them in the database, and then query them in the database. For example:
< pre t = "code" L = "Java" > varaddr = & quot& quot;< br />varfilter=web3.eth.filter({fromB lock:0 ,toBlock:' latest', address:addr });< br />filter.get(function(err,transactions){transactions.forEach(function(tx){
vartxInfo=web3.eth.getTransaction(tx.transactionHash);
/ / at this time, the transaction information txinfo can be stored in the database
})< br />}); Pre >
Web3. Eth. Filter() is used to monitor the log on the chain, and Web3. Eth. Gettransaction() is used to extract the information of the specified transaction. Once the transaction information is obtained, it can be stored in the database for query
recommend a practical introction, you can see: Ethereum tutorial
the working principle of nativscript: calling native API with JavaScript to realize cross platform
nativscript is a cross platform solution recently launched, which allows you to directly write Android and IOS local applications with JavaScript, It will be extended to Windows platform in the future. It's a project that has received more attention recently. It is essentially different from NW (formerly known as node WebKit, using web to write winodw / Linux desktop application) and phonegap embedded WebView to write app. It calls the system native API directly with JavaScript, so it has some native application characteristics.
railway station - material Station - Bayi Road Crossing - Municipal Auto Parts Corporation - North Wenhua Road Crossing - silk weaving factory - Municipal stomatological hospital - Central Hospital - Guanghui Machinery Factory - Shangzhuang - qiliyuan - oil pump and Nozzle Factory - Armed Police Training Squadron - Dushan - liushudian - Huaishuwan - huangquhe - cotton depot - jingwa - konghou Cement Factory No.3 - Railway Station - Weixue road crossing - erjiao factory - Wolong Gang - agricultural school - jade factory - Wolong bridge - Nanyang Hotel - Wolong District Party committee - Municipal First Hospital - Cultural Palace - People's Park - silk weaving factory bridge - Municipal stomatological hospital - Nanhang building - Municipal People's Congress and CPPCC - Huadong village - Wolong District Court - sifujing - Nanyang steel market - Provincial Economic Management School - Nanyang evening news NO.4 - Railway Station - Wolong District First Hospital - Nan Hotel - Intermediate Court Party School Wolong bridge Baihe Avenue entrance Baihe gas station Yuwan pharmaceutical factory Nanyang lubricating oil factory Nanyang cotton textile factory Dechang Aluminum Company brewery Nanyang transformer factory Kangyuan General Factory Baihe Town Government Baihe Town Health Center Jinyuan edible oil factory (Weiying) No.5 railway station material station Bayi Road Kou - pharmaceutical packaging factory - Municipal chemical pharmaceutical factory - Municipal stomatological hospital - Central Hospital - explosion proof factory - Guanghui Machinery Factory - Kangyuan factory - east ring road crossing - Wanshunda company - Automobile Leaf Spring Factory - Wangying - Fangzhuang - Zhuzhuang - Liuzhuang - penyao - Airport Road Crossing - Xindian road crossing - leizhuang - Fanying - zhangxiaozhuang - Rose Group - yingzhuang - Yingbei road crossing - Hongxin road crossing - Xinxin road crossing Dianxiang government No.7 -
railway station - material Station - Textile Station - cultural intersection - maternal and child health care center - City Square - Fangyuan audit institute - Qiyi intersection - Wolong bridge - Baihe Avenue entrance - Shiwu middle school - Yuyang bridge - Yuyang middle school - political and legal cadre school - Hot Spring Garden - Baihe Garden Apartment - Baihe bridge - Nanxin intersection - Shangyuan instry and trade market - Zhaoying No.8 road - Railway Station - Xinhua Shopping mall Bayi Road crossing instrial road crossing municipal agricultural machinery company YuShuZhuang Qilin road crossing Qiju hospital Jingang township government Hepatobiliary Hospital chuanguangchang Huanggang village National Highway 312 Jingang village No.10 Railway Station Station Station Road Zhongzhou Road lixi road Qilin Road Beijing Road 312 National Highway jilongwang village Jichang No.12 railway station weixiaokou lixi road crossing -Beijing Avenue - Cuizhuang - Wuhou intersection - Nanyang Teachers College - gong'an automobile school - shierlihe - shuangshibei - reform through labor center - Zhenggang - Xindian - Zhengda feed company - runzhuang - Wulipu - shibazhong - Liaohe town No.15 - Railway Station - International Hotel - Textile Station - Wenhua intersection - Bayi intersection - north entrance of Wenhua Road - Nanyang Power Plant - Li Garden Hotel - wujiaohua company - workers and peasants Intersection - Central Hospital - Guangwu intersection - Hanye Youyuan - Hanye village - Wanzheng community - qiliyuan south entrance - Xingguang school - zhangheng intersection - Gaoxin intersection - qiliyuan East Entrance - Wolong driving school - oil pump nozzle factory - municipal vehicle management office - Dushan army - Dushan village committee - Dushan Cemetery - Xingying - dashiying No. 16 Road - Railway Station - Health School - erjiao factory - WoLonggang art high school - pengying -Financial Cadre School Tangwan Wangying Jinniu color printing company paint chemical factory zinc company No.17 Railway Station International Hotel Textile Station Wenhua Road Bayi Road North Wenhua Road Nanyang Power Plant Lido Garden Hotel wujiaohua company Gongnong Road Central Hospital Guangwu road Hanye Youyuan Hanye village Wanzheng community qiliyuan south entrance- Xingguangxue - zhangheng intersection - Mingshan intersection - Xingwan school - steel pipe factory - traffic driving school - Dazhuang - Datun intersection - Datun school - Datun village committee Henan Institute of technology No. 18 - Railway Station - Health School - Qiyi road - traditional Chinese medicine hospital - municipal court - normal school - Nanyang Hotel - Wolong District Committee - Fuyang bridge - Jiefang square - Xuechang intersection - Yanchang - yishengci - weigongqiao - east bus station - explosion proof Road No.20, qiliyuan east station, qiliyuan station (pain hospital) -
railway station, railway station, freight yard, Sanliqiao, Bayi Road crossing, municipal Auto Parts Corporation, Jianxi road crossing, Bayi Road crossing, Xinhua Road crossing, maternal and child health care center, city square, Fangyuan audit office, Qiyi road crossing, Wolong bridge, Baihe Avenue crossing -Baihe gas station - Municipal Radio Station - happy community - No.1 Cotton Factory - Fangyuan pharmaceutical company No.21 - Railway Station - Health School - Nan Hotel - Nanyang cinema - Party School - Wolong bridge - Tongle Lane - Fubin bridge - Jiefang square - longquange - No.2 technical school - Baozhuang - Xinhua intersection - herbal medicine market - Wancheng hospital - Dongyuan community - chaizhuang intersection - wufujing - bus ring east parking Chang Xingwan school Nanyang steel pipe plant traffic driving school
可以,只要你是用webview打开的,那么不管事远程还是本地,都可以通过webview与app的本地java代码进行交互没有任何区别
1、webview必须设置支持Javascript
mWebview.getSettings().setJavaScriptEnabled(true);
2、加进一个回调的代理类JavaScriptInterface,并给它一个调用的名称:ncp
mWebView.addJavascriptInterface(newJavaScriptInterface(),"ncp");
finalclassJavaScriptInterface{
publicintcallOnJs(){
return1000;
}
publicvoidcallOnJs2(Stringmode){
//TODO
}
}
3、JS页面
<scripttype="text/javascript">
window.onload=function(){
document.getElementById('btn_1').addEventListener('click',onBtnClick,false);
var_int_value=window.ncp.callOnJs();
alert("getintfromjava:"+_int_value);
}
functiononBtnClick(){
window.ncp.callOnJs2("click");
}
</script>
接下来就可以调用js方法了,
1、Java调用js方法
mWebView.loadUrl("javascript:onSaveCallback()");2、JS访问java方法
window.ncp.callOnJs2("click");
bus line: No.14, the whole journey is about 3.2km
1. Walk about 170m from Nanyang railway station to the railway station
2. Take No.14, pass 5 stops, and reach Yuwan Hotel Station
3. Walk about 310m to Nanyang first people's hospital
and then enter the hotfix folder under your 360 installation directory to find the file installation of windows xp-kbxxxxx (X represents the digital code of the patch you want to install) - x86-chs
