简体   繁体   中英

how to get acknowledgement from php to android for received data

i am sending username and password to php pages for authentication. want acknowledgement from php to android if password matched or not. username and passwords are saved in mysql database. php file is connected to mysql database.

If username and password are sending by the android app, so just read the result of your get or put request, your php page can send the result easily for you. but if another client is sending the username/password and android app is going to receive login data, there are two way

  1. pulling: add a function in your php server to receive last login data from database and call it in your android app, periodically.
  2. Event base: add a socket server in your android app and send data from php function to your android application by socket based on it's logging event, in this way you receive the login event on time.

I do not recommend the second way, because it have some limitation and it's hard to implement in mobile platform, it needs android service and you must make sure that socket server is always running.

If I'm not mistaken, when you are calling the php, you can get your result (validation) and echo it.

If the operation is long, you can use a queue structure, and check for your position in the queue and for it's results when executed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM