こんにちは、NanoHttpd を使用して Android 用の Web サーバーを作成しています。実行すると、Activity が機能しなくなったと表示されます。どうすればよいか教えてください。これは私が使用しているコードです。コードは次のとおりです。
package dolphin.developers.com;
import java.io.IOException;
import java.util.Map;
public class MyHTTPD extends NanoHTTPD {
/**
* Constructs an HTTP server on given port.
*/
public MyHTTPD()throws IOException {
super(8080);
}
@Override
public Response serve( String uri, Method method,
Map<String, String> header, Map<String, String> parms,
Map<String, String> files )
{
System.out.println( method + " '222" + uri + "' " );
String msg = "<html><body><h1>Hello server</h1>\n";
if ( parms.get("username") == null )
msg +=
"<form action='?' method='get'>\n" +
" <p>Your name: <input type='text' name='username'></p>\n" +
"</form>\n";
else
msg += "<p>Hello, " + parms.get("username") + "!</p>";
msg += "</body></html>\n";
return new NanoHTTPD.Response(msg );
}
public static void main( String[] args )
{
try
{
new MyHTTPD();
}
catch( IOException ioe )
{
System.err.println( "Couldn't start server:\n" + ioe );
System.exit( -1 );
}
System.out.println( "Listening on port 8080. Hit Enter to stop.\n" );
try { System.in.read(); } catch( Throwable t ) {
System.out.println("read error");
};
}
}
LogCat:
07-14 22:35:26.394: E/AndroidRuntime(581): FATAL EXCEPTION: main
07-14 22:35:26.394: E/AndroidRuntime(581): android.content.ActivityNotFoundException: Unable to find explicit activity class {dolphin.devlopers.com/dolphin.developers.com.MyHTTPD}; have you declared this activity in your AndroidManifest.xml?
07-14 22:35:26.394: E/AndroidRuntime(581): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
07-14 22:35:26.394: E/AndroidRuntime(581): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
07-14 22:35:26.394: E/AndroidRuntime(581): at android.app.Activity.startActivityForResult(Activity.java:2817)
07-14 22:35:26.394: E/AndroidRuntime(581): at android.app.Activity.startActivity(Activity.java:2923)
07-14 22:35:26.394: E/AndroidRuntime(581): at dolphin.developers.com.facebook1$DownloadFileFromURL.onPostExecute(facebook1.java:167)