Programming Blog




Article - 06
"Mobile Site"

(30.01.2021)

I was doing a mobile version of the website and ran into a couple of things,
that I'd like to talk about:
In a few words, the app sends and receives reqests to the server,
and then reads and writes the data into the database.

I use the HTTP library volley to send the requests, it makes working with requests easier and faster.
The first thing I encountered is that volley caches requests, which is quite a hindrance to development.
Because despite the changes in the request code, the response is still the same and inexperience you might think,
that the changes don't work.
You have to restart the virtual device (cold boot) or remove the application on the physical one,
or you can disable caching during development.

request.setShouldCache(false);
Next, the problems on the side of the site.
The site written in php and the external client was not planned.
Therefore, in order to make the android app work with the site, I had to change the site itself.

First.
Identity in php sends a form with login/registration data.
Then php accepts the form, extracts the data and works with it.
The thing is, if js has a FormData() object, then java doesn't know how to send forms.
The exchange can be json`, and you can't get the data being sent through the $_POST variable
And the site has to take the data directly from the php://input file and convert it to a string:
file_get_contents('php://input');
When identified, php creates or resumes a session cookie:PHPSESSID=xxx with session_start().
But android is a cookie-less client, that is, it does not generate cookies.
So we have to save server-generated cookies into a database and send them between the client and the server.

These are the problems I encountered in creating website.
Thank you for your attention.

Back

Back to start