android 调用webview控件,为逆向h5app做准备
2018-01-15 17:02
483 查看
activity对应layout文件加入:
activity代码 :
以下为5.1机器上测试,js无法调用未导出的组件方法,
<WebView android:id="@+id/main_web" android:layout_width="match_parent" android:layout_height="match_parent"> </WebView>
activity代码 :
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWeb = (WebView)findViewById(R.id.main_web); mWeb.getSettings().setJavaScriptEnabled(true); //覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为,使网页用WebView打开 mWeb.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { //返回值是true的时候控制去WebView打开,为false调用系统浏览器或第三方浏览器 view.loadUrl(url); return true; } });
以下为5.1机器上测试,js无法调用未导出的组件方法,
hello为导出的类对象。不知道大神是用的什么方法调起来的
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script type="text/javascript"> function test() { ob1=window.hello if(ob1!=null) { cls=ob1.getClass() if(cls==null) { return } rt=cls.forName("java.lang.Runtime") if(rt!=null) { rt.getMethod("getRuntime").invoke().exec("echo 111"); } } } </script> <title></title> </head> <body> <input type="button" value="返回安卓的某一个界面" onclick="test()"/> </body> </html>
相关文章推荐
- Android WebView 微信和支付宝H5调用本地app支付
- android-webView与H5的调用
- Android控件之WebView(网页调转回APP)
- android:如何通过chrome远程调试APP中的webView的h5代码
- Android - 使用自定义webview调用支付宝app支付
- Webview之H5页面调用android的图库及文件管理
- android WebView调用文件管理器,点击返回键退出app的解决办法
- Xamarin Android Webview中JS调用App中的C#方法
- Webview之H5页面调用android的图库及文件管理
- 用webview构建能打开微信支付宝支付、自动跳转域名的Android H5APP
- 深坑之Webview,解决H5调用android相机拍照和录像
- android webview 调用微信 h5 支付方式
- android中webView加载H5,JS不能调用问题的解决
- 使用Android的WebView控件调用本地代码
- Android APP 使用WebView访问服务器H5页面带上Cookie
- Android中通过WebView控件实现与JavaScript方法相互调用的地图应用
- Android通过Chrome Inspect调试WebView的H5 App出现空白页面的解决方法(不需要FQ)
- Webview之H5页面调用android的图库及文件管理
- Android WebView控件的显示,调用网页,然后隐藏
- 系出名门Android(7) - 控件(View)之ZoomControls, Include, VideoView, WebView, RatingBar, Tab