nanohttpd - android change textview text based on http request -


i want make http server in android serve file (html/png..) doing event based on request.

example: if request /maketoast android make toast or request /chanhetext android change specific textview text.

point is: make server nanohttpd. it's serve files, don't make event, make toast or change textview text.

here nanohttpd serve method

   public response serve(ihttpsession session) {        string msg = "<html><body><h1>hello server</h1>\n";        map<string, string> parms = session.getparms();        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><img src=max.png/>";        }        //toast.maketext(mcontext, "helloooooo...!!!", toast.length_short).show();        return newfixedlengthresponse( msg + "</body></html>\n" );     } 

when try make toast server going freeze , doesn't give response. can 1 please tell me how make kind of thing.

try:

getactivity().runonuithread(new runnable() {         @override         public void run() {            toast.maketext(mcontext, "helloooooo...!!!", toast.length_short).show();         }     }); 

Comments