I am currently working on an application for android. My background is web development and I have been using ajax to update information on the screen from a server without reloading the page. I was wondering (and maybe many others as well) what is the equivalent to ajax for android?
The goal is to have the contents of an activity updated or changed with the same asynchronous flow as ajax. Examples of the usage would be things like a messenger or an list updated from a database.
I know this is a newbie question but I hope this might also help others.
Update I am using Volley for server communication
I think AsynkTask with notifydataSetChange in recycler view adapter will be helpful.
Another way is to create a service and call notifydataSetChange if the existing json not equal to the json already at the app.
Related
I want to create an app for a website that I don't own, like youtube or reddit. Every time I search for help, all I keep getting is how to create a webview. I've done that but that's not what I want. I want to take the website's content and create an app with it, like create my own buttons and such. I want to convert a website into an app.
I was thinking of somehow loading the website in the background and creating activities/buttons/intents that basically do what the webpage does but I don't know how to go about that or if there's a better way.
Thank you in advance.
Please let me know if clarification is needed.
Alright i got -3 votes for some reason and it has been 12 hours since i posted this question, i'm guessing the question has been consumed by the abyss of questions by now.
I made a reddit post and got some responses:
one user:
The term you’re looking for is “web scraping“ or “site scraping”. I think that’s probably what you need to research before you’re ready to handle how to make that into an app.
That’s a good starting point and once you have the content from scraping, making the app is no different than any other app.
second user:
If the website has a public (or private) API, you can use your buttons and networking calls to their API to build your client app. You are building a "YouTube client" in this case using the YouTube API.
If they dont have an API and you don't want to display their website, what you are doing is trying to reverse engineer their website and hijack the UI which is not a good practice and may even be illegal depending on the site and terms.
third user:
#second user is right on the money, but one thing I'll like to add is, the goal is to get data off of the website so that you can use in your app. An API is one (convenient) way of doing that but others are,
RSS or similar feed content (prefer this if there website supports)
HTML scraping
The above two will require you store the data somewhere else (and possible expose an API instead) because of technical reasons: you don't have access to older entries in RSS feeds and it's atrocious to keep on scraping everytime you need to access the website data. They can be done on the client (mobile app) but are best done on a server. This means you might need to get your hands dirty writing server code but you don't have to.
/thread
I'm going to do research on website scrapping and APIs to see which route i should go.
Hopefully this helped someone else.
I'm currently trying to work out what technology I can use to fire events remotely when a database changes, a realtime database of sorts. There is both an android application and a desktop JavaFx app that will communicate via the same database. When the data is changed from the desktop side, I'd like Android to update its data, and vice versa when changes occur on Android. Is there any method to achieve this without polling the DB for changes regularly?
I looked into Firebase and it seemed perfect, but lacked a desktop java library. Similarly, I have experimented with Amazon AWS Lambda and DynamoDB, and I can get a Lambda function to fire when the DynamoDB table changes. I can't however find a way for the Lambda function to update the Android/Desktop application that the data has changed though.
The JavaFx desktop application is a requirement of the project.
Apologies if this isn't possible, or if I'm overlooking a well known platform for this issue. Any help would be greatly appreciated.
No you not need the process of polling to achieve your results. To answer the first question, first the most flexible and plausible approach would to built a middle ware to intercept any changes.
Create a script to fire events whenever the data base changes. Wether by a time interval.
Second create server, a real-time server to fire such events to any client.
Third, the java fx client can use native observable for such a task. However i proposed going with a common listener, a perfect choice would be socket.io, there web-socket implementation available for android and vanilla java. For android client, whenever a data is inserted , transformed etc , use a broadcast receiver(local) to fire events in the to notify the server. Or use the socket.io connection to send events. Thats pretty much it.
Firebase + Cloud Functions for Firebase sound perfect for your use case. If the matter is pure Java support for Firebase, rather than Android, you might want to check out this question Get Firebase to work with java, not Android
I am beginner in Android development and I am trying to make an app that will simply display the posts on the following website http://www.montgomeryschoolsmd.org/schools/lakelandsparkms/. I need to know how can I display the data from the web into my android app. An example would be appreciated.
The easiest way to display posts into an Android application will be to use JSON data on the web, and read it into a Master Detail Android application.
On the website side, getting the data to display in JSON seems to be the most difficult part of your problem. It would be easy if it was a Wordpress site, as there are plugins that will do this for you.
On the application side, getting the data and parsing it into a master detail flow is a fairly trivial task.
Something like this tutorial may help: http://www.technotalkative.com/android-json-parsing/ or this video https://www.youtube.com/watch?v=0TulTqQM0Cc
You can make a Json request and show data with android views. Or you can download the full or partial page and show it directly in a webview.
Use Jsoup if you're trying to scrape the webpage for data and display it in a UI.
i have a wordpress blog hosted over my personal shared hosting.Now i want to develop an android app for that blog so the users can use the mobile app to see what i am writing on my blog.
Like for example you can take mashable.com android app.
so basically i have experience in programming android aap but i am just asking this so i can code it in a better way.
i have 3 idea to do this now:
1.Use rss feed of my blog and parse it and display the contents but it has a issue that rss only display most latest contents.So whether i need to store the feed contents timely on android device so a user can view the previous most content also.
But i think it's not a good idea because it will unnecessarily increase the size of database and make diff copies on every device.
2.Just simply use complete java code to pull data from my web mysql database as per the user request and just display it over the screen without storing it locally on android device.
3.Develop some sort of API solution on my web server then send the data in json or xml format so i can use it on my android device(via java) without bothering to connecting to mysql server as a core part because that part already done by on web server and my api already sending data in required format.
So these are 3 idea i have now.So please suggest me a better one form these three or you can give any other idea.
I am asking this question because previously i never programmed this sort of mobile aap where i need to pull the data from remote server.
-Thanks
You can simply install WordPress Mobile Pack to display Mobile site of your wordpress blog/site
Or
You can check this link to find out other plugins: 11 Ways to Create a Mobile Friendly WordPress Site
Now, If you want to create an app then you can simply implement it by using WebView.
I'm writing a simple XMPP Client in android, I've extracted all the XMPP Calls to a nice helper module. That module writes any incoming XMPP Messages to a SQLite database.
When the app opens a view of a user, it grabs a copy of the latest messages from the SQLite db (easy enough).
However if a XMPP Message was to come in whilst the user is viewing that "ListView" is there anyway bubble a message down a tree to tell a view to update?
The XMPP Client is run in the Application context if that helps at all.
Use ContentProvider and ContentObserver, its a good implementation of the observer pattern, which is exactly what you need. The Adapter providing the content to the ListView even handles practically all of the observation side, you'll just need to implement your own ContentProvider
Use listview.notifyDataSetChanged() and the listview will handle the rest :)