NanoHTTPD 服务
16lz
2021-01-26
public class MyWebServer extends NanoHTTPD { private FaceEngine faceEngineWeb; private final static int PORT = 33445; private Context _mainContext; private static boolean isRun = false; HttpRequestUtil httpRequestUtil =new HttpRequestUtil(); /* private String deviceKey = Myapp.getBaseData().getDeviceKey(); private String passKey = Myapp.getBaseData().getPassKey();*/ 主构造函数,也用来启动http服务 */ public MyWebServer(Context context) throws IOException { super(PORT); _mainContext = context; start(); } /* 解析的主入口函数,所有请求从这里进,也从这里出 */ @Override public Response serve(IHTTPSession session) { return newFixedLengthResponse( "" ); }}
//调用
MyWebServer mywebserver = new MyWebServer(this);
//销毁
if (mywebserver != null) { mywebserver.closeAllConnections(); mywebserver = null;}
更多相关文章
- Android(安卓)frameworks Singleton
- java 编译中常用函数
- 在 Android(安卓)开发中使用协程 | 上手指南
- 阿里ctf-2014 android 第三题——andriod模拟器安装
- Android(安卓)or Linux 的休眠与唤醒
- 用Android线程间通信的Message机制
- Android(安卓)通过 JNI 调用 Java 类的构造方法和父类的方法
- Flutter系列之UI篇:flutter与android UI构建的区别—flutter widg
- 【Android】Android系统启动过程