android - 在 Android 应用程序中运行网络服务器

标签 android webserver android-webview

我有一个 Android 应用程序,它使用 webview 来显示它的一些屏幕。 问题 - android webview 页面需要花费大量时间从远程服务器下载图像。因此,我考虑在我的 Android 应用程序中(在一个新线程中)启动一个网络服务器来提供静态图像。

我能够在端口 8080 上的线程中启动网络服务器(从我的应用程序),但无法通过 URL“10.0.2.2:8080”、“127.0.0.1:”上的 webview 从我的应用程序访问它8080”和“本地主机:8080”。 知道为什么我无法访问我的网络服务器吗?

提前致谢!

最佳答案

您会考虑直接将 HTML 数据加载到 webview 中吗?

String summary = "<html><body>You scored <b>192</b> points.</body></html>";
webview.loadData(summary, "text/html", "utf-8");

关于android - 在 Android 应用程序中运行网络服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5938371/

相关文章:

android - 在不创建新文件的情况下裁剪图像

php - XAMPP 运行 Apache 但不运行 MySQL

javascript - 使用 Nodejs 提供图像

android - WebView 和 HTML5 <视频>

android - 删除本地存储但仍然存在

android - java.io.IOException : FIS_AUTH_ERROR in Android Firebase but DEBUG mode ok

android - 是否可以设置一个IntelliJ Android项目以与Maven一起使用?

java - 无法在我的 Android 应用程序中获取电话号码

go - Go语言内置的http服务器是生产服务器吗?

android - 当应用程序离开后台并返回 iOS 和 Android 时,WebView 正在重新加载?