我想制作一个使用 nanohttp 来创建 Web 服务器的 android 应用程序,此代码不会给我一个错误,但是当我在端口 8000 上的浏览器中键入 ip addr 时,它说连接超时请帮助任何帮助将在这里得到代码..
package dolphin.developers.com;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import dolphin.devlopers.com.R;
public class AnroidWebServerActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public class MyHTTPDs extends NanoHTTPD_2 {
public MyHTTPDs(int port, File wwwroot) throws IOException {
super(8000,new File("."));
// TODO Auto-generated constructor stub
}
@Override
public Response serve( String uri, String method, Properties header, Properties parms, Properties files ) {
File rootsd = Environment.getExternalStorageDirectory();
File path = new File(rootsd.getAbsolutePath() + "/");
Response r = super.serveFile("index.htm.html", header, path, true);
return r;
}
}}
并且日志猫没有给我任何错误,所以我没有发布它......