Featured post
Android - Ajax style auto check of username availability -
i building android app in user required choose nick name. now, 2 users cannot have same nick name. have seen forms on .net can verify availability of particular username while user types or presses tab using ajax calls.
my questions - available android. can query server on fly , verify availability of nick name.
thanks lot responses. if there tutorials, samples or android doc references need @ please guide me that.
you could query server's database of users entered username on every keypress event specified input component(edittext
, etc), might pretty network intensive , spawn lot of threads handle:
- add
textwatcher
inputedittext
or whatever user entering name into - in
ontextchanged
method, spawn thread contact database sending alongcharsequence
value. response server output json perhaps boolean property says if username available or not - user hits "ok" , expects name registered themself. final check needs made before nickname, availability may have changed since(say ton of people registering @ once)
or...
- let user type in desired name
- let them hit "save" or "register"
- at point, send along registration data , save in database if name available. otherwise, let user know isn't , must try again
or...
when app starts(right before must pick name), contact server's database , send app response holding list of names taken.
this way, can check if name taken locally on phone rather sending off request check.
you must still check availability of nickname right before saving on server side
edit: i've implemented #2, seems that's majority of apps registering unique name(that ive seen)
problem #1 - user enters in 1 letter(network thread started) - user enteres letter(another thread started) - user enters 3rd letter(another thread) - thread 2 finishes first, name valid, user notified - thread 1 finishes, name invalid, user notified - thread 3 finishes, name invalid, user notified
thread 2 took 4 seconds thread 1 took 5 seconds thread 3 took 5 seconds
say user keeps typing 25 letters, there lot have keep track of in terms if name valid or not, if , threads still running, etc
this approach seems bit tedious such simple registration task, hassle
problem #3 - requires 1 network request server
i approach because can , notify user if name available without threading(depending how large user list is) or worrying how long take check
number 2 simple, easy, , can have chance require 1 server request
- Get link
- X
- Other Apps
Comments
Post a Comment