I have a service called EventReceivingSevice
which will get new data in onDataRefresh(JSONObject data)
function.
private void onNewData(JSONData data) {
boolean isActive=isActivityActive(); //Check if activity is active
if(isACtive)
passData(data);
else
storeData(data);
}
An activity called HomeActivity
will display the data. When EventReceivingService
will get new data, it has to be checked if HomeActivity
is active, it has to pass the data to HomeActivity
, and if not it will store the data somewhere so that HomeActivity
will later use that.
The data is in JSON format.
How can achieve this?