I'm making a small application which has a feed. so I'm retrieving posts from parse using a simple query, and I'm caching all theses posts to give an access when the user is offline, and when a new post is added to parse I want to inform the user so he can see the new posts.
so is there anyway to schedule the parse query in android, or run it in background every 30 seconds to see if is there any new posts.
Here is my query code :
ParseQuery<ParseObject> query = ParseQuery.getQuery("Feed");
query.setCachePolicy(ParseQuery.CachePolicy.CACHE_THEN_NETWORK);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> feedList, ParseException e) {
if (e == null) {
for (int i=0;i<feedList.size();i++)
{
Post p = new Post(feedList.get(i).get("Text").toString());
PostList.add(p);
}
Log.d("result","Here is it:"+PostList.size());
mAdapter = new FeedAdapter(PostList);
mRecyclerView.setAdapter(mAdapter);
} else {
Log.d("Feed", "Error: " + e.getMessage());
}
}
});