知识点:

1)android 和 html 的集成  2)html 如何通过javascript 判断 客户端是 android 还是 IOS3)IOS 和android 的集成 (我不懂IOS 的oc 开发,所以这部分我省略。。。。我是和我的一个IOS同事一同测试过的,html 是我写的)
html的代码
商城红包模拟页面    

商品列表

神州笔记本电脑 3000.00 元 点我下单 联想笔记本电脑 5000.00 元 点我下单

Android  代码

package com.htjc.baseframe;import java.io.UnsupportedEncodingException;import java.net.URLDecoder;import android.annotation.SuppressLint;import android.os.Bundle;import android.util.Log;import android.webkit.JavascriptInterface;import android.webkit.WebSettings;import android.webkit.WebView;import android.widget.LinearLayout;public class WebViewActivityextends BaseActivtiy{private WebView webview;private LinearLayout ll_rootView;@SuppressLint({"SetJavaScriptEnabled", "JavascriptInterface" })@Overrideprotected void onCreate(BundlesavedInstanceState) {super.onCreate(savedInstanceState);ll_rootView = new LinearLayout(this);ll_rootView.setOrientation(LinearLayout.VERTICAL);webview = new WebView(this);WebSettings settings =webview.getSettings();settings.setJavaScriptEnabled(true);// webview.loadUrl("http://192.168.1.117:8080/webview/test.html");  webview.loadUrl("file:///android_asset/test.html");  webview.addJavascriptInterface(new JavaScriptObject(),"myObj");  ll_rootView.addView(webview);setContentView(ll_rootView);}public class JavaScriptObject {  @JavascriptInterface    /**    * 此方法用于下单操作    * @param name    */    public void dopay(Stringname){      Log.i("xiexie",name+"----");      String result="";      try {        result = URLDecoder.decode(name,"UTF-8");      } catch (UnsupportedEncodingExceptione) {      e.printStackTrace();    }    System.out.println(result);    Log.i("xiexie11",result+"----");    }}  }

更多相关文章

  1. Android 轻松实现语音识别的完整代码[转]
  2. Android Studio 添加 C、C++ 代码
  3. Android 实现语音识别的完整代码
  4. Android 中使用代码动态网格布局
  5. 安卓视频播放器 一行代码快速实现视频播放,Android视频播放,Androi
  6. Android Zip文件解压缩代码
  7. Android如何完全调试framework层代码
  8. android studio如何生成混淆代码的jar
  9. 狂刷Android范例之4:用代码安装卸载app

随机推荐

  1. android 中对xml 进行解析
  2. android 禁止输入特殊字符
  3. Memory Analyzer(MAT)打开android eclipse
  4. android中菜单的使用
  5. Android(安卓)Re-installation failed解
  6. 【Android】SQLite数据库的简单使用
  7. Android隐藏ListView的滚动条
  8. Android(安卓)Uri转换成真实File路径
  9. Android时间选择器
  10. android ListView TV 通过遥控器上下 smo