It is possible yes, if you use a function in the Android application that is always run at a set time (every 1 minute, for example). This function should look up if Webservice has new notifications for that user.
Edited
I found a tutorial that shows how to consume a JSON
on Android: http://www.devmedia.com.br/consumindo-json-em-aplicacoes-android/27589.
What you should do is add a method that will fetch the Webservice (I always use in REST for already knowing) always every x seconds/minutes. In the PHP application, when running the REST method (if you have something to send to the Android application), you provide the information and, after running on Android, you should remove this information from the WS (logically or physically), so that there is no duplication of information sent
Edited 2
After configuring the Androidmanifest file so that the user has access to the internet and imported the package of JSON
, the method is created (in this example, it is executed every 5000 ms, that is, every 5 seconds):
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
super.onCreate(savedInstanceState);
new DownloadJsonAsyncTask()
.execute("http://meusite.com.br.meujson.json");
}
}, 0, 5000);
No WS PHP
:
<?php
$objetosJson = [];
$objetosJson[] = array('Objeto' => array('id' => 1, 'nome' => 'João'));
$objetosJson[] = array('Objeto' => array('id' => 2, 'nome' => 'Maria'));
echo json_encode($objetosJson);die;
Julyano good morning, you have some practical example of this ?
– Matheus Arruda
I will provide an example, a moment.
– Julyano Felipe
Can you illustrate with code here what is in the link? Answers that depend on links are not encouraged here, will in the future this link become inaccessible?
– user28595