Android do authentication constantly with external server

Asked

Viewed 285 times

1

Staff would like to know how to do for the application I’m developing make authentication constantly.

For example the watts if you don’t have access to the internet and try to send a message it is saved and the app is constantly trying to send this message and when you have access to the internet it sends the message to the server immediately.

In my case my app will have a desktop version that way I will use the server to synchronize the user information between the two devices, for example the user accesses with his login the Android app and changes his profile image so the app updates this image locally and then sends it to the server and when the user opens the desktop version app he downloads this server update and vice versa.

Does anyone know how to do this? I am using wampserver + php.

2 answers

0

It’s all a matter of developer logic.
I would do as follows ex: case of Whatsapp messages quoted by you.
Create a column in my table called STATUS, in it I would save the following information:
0-message not sent
1-message sent
If (at the time the user typed the message,sent has the internet) save with status 1
otherwise (saved with status 0 because the message was not sent) following.
Every time the user opens the application and is with internet or the app is closed and a Broadcastreceiver detect the presence of internet, would make a select in all messages with status 0 (or messages that have not been sent) and since now you are going to have the internet to send the message (following the business rule 'only send message if you are connected to the internet') update the message to status 1 (that symbolizes successfully sent messages)

  • the logic of when to send I know the problem is to make the app be constantly checking the connection to the server and I think you do not know but watts does not check the connection to the internet and yes to the server, that is even with the internet connection if the server is not available it does not send.

0


Good with my researches I found a way that at first I found an exaggeration for a simple task, but as I did not find any better way so I will use this. I will use the Sync Adapter class along with others I saw in the Android documentation that from what I read it makes this constant connection check with the server ta ai the link for those who need:

http://developer.android.com/intl/pt-br/training/sync-adapters/index.html

Thanks for the previous reply @Alessandro Barreto.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.