I'm trying to figure out how to have a real time data displayed on a webpage through the use of an android app.
For example, users are using android app and are scored (answering questions). My webpage will display the scores in order in real-time.
Iv come to the conclusion to use Redis, but what exactly do i need for this to function? Do i need a web socket where my web page will communicate with. This socket could be python where it accesses the database and then responds with the scores in order?
Im struggling to find out how exactly this would work as this is new to me. What exactly should i be looking for (terminology etc)?
Thanks
One approach might be:
set up a database on a server on the internet
program your app to save data to that remote database
set up a webservice
program the webservice to read data from the database and serve it as an html page
For extra credit
implement a REST style API which retrieves and serves data from the database
create an ajax webpage which uses the API to fetch and display data (so you don't have to refresh the page constantly)
Related
I'm a complete newbie in android development with some basic programming knowledge. Right now, I want to develop an E-Commerce app which allows the user to upload pictures for the public to browse through. However, I have no idea how should I store all the data, including the details(username and password) of the user, in the server. As far as I know, the database most often used in android is SQLite, but I'm not sure whether it's suitable to be used in my case.
Please shed some light. Any form of help would be much appreciated. Thanks in advance.
You could set-up a backend using some database (eg. MySQL) and some programming language (eg. PHP) as well as some kind of web-server (eg. Apache).
You would store the products,user data in tables of the database. Pictures would be stored on some directory on your server and you could store references to their path in the respective fields.
Your client (android) would load the products list as well as submit new products via issuing requests to your server back end, and perhaps store them in some SQLite database if you need the old items viewed to remain viewable without an internet connection.
A few tutorials to get you started:
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
http://www.tutorialspoint.com/android/android_php_mysql.htm
If you'll create an e-commerce mobile app, it cannot exists as a mobile app alone because it needs to connect to other users. You need to integrate it to a web service or a cloud service to tasks such as getting the item data, images, and other tasks involved. There are Baas (cloud) that you can use such as Parse and Kinvey.
I have started working on an Android app for which we need to use MySQL as database and Ruby on Rails for server side code. We will be using SQLLite too on device(will sync both DB as and when required). I searched the web and couldn't find any relevant tutorials/examples which can serve as a base to start with.
I have gone through MySQL and ROR tutorials but still has confusion on connecting Android with ROR.
Can somebody share some relevant tutorials/code snippet which can explain the complete linkage of the technologies. I mean how to send data from Android device to MySQL and vice versa. I know the concept theoretically but not sure how and where to start with.
My sincere apologies for asking such a basic question or if I sound ambiguous but I am a beginner and need to complete this task. Thanks in Anticipation..
Here is a brief overview of what you should know to accomplish your goal. I am not going to go that far into detail, especially since I have never personally used RoR. Note that some of these parts might not relate exactly to RoR, but the general idea behind it still applies. I will leave it up to you to research and figure out how to implement each individual component.
The general flow of everything is as follows:
Android App <==> Network <==> Web Service <==> MySQL
Note the double-edged arrows since data will be flowing in both directions.
The Android App is the client, and the Web Service and MySQL database are located on your Web Server. I only included the Network part for completeness, but you shouldn't have to do anything once the data has been sent onto the network.
A brief overview of each section:
Android App:
The Android App is the client that sends and retrieves data from the Web Server. I am assuming that in your app you are going to allow the user to do some tasks which in essence becomes the data that you want to send to the server at some point.
Take for example, the user should be able to enter his name and favorite animal. Lets say that there is an actual "Submit" button that the user may click. When this "Submit" button is clicked, it should wrap up the data into a proper format to be sent across the network. Two of the most common ones are JSON and XML. Once the data has been formatted properly, you will want to send the data to the server using some type of network protocol such as HTTP. In order to send the data, you of course must have some URL as the target. Lets say the target is www.example.com/webservice.php. This target is our Web Service located on the Web Server.
Once you send the data, the server will respond with some data at which point you can do whatever you want with it. Maybe display it to the user, or stick it in an SQLite database, or even both.
The key thing to remember is that there is no magic going on. Everything I have just described will be implemented in Java code that you will write in your Android Application at some point.
Key Ideas you should research more and figure out how to implement in Java code:
JSON and XML
HTTP in Java
REST and SOAP
Here is an excellent video on possible ways to set up the structure of your Android App.
Make sure that you are doing all network operations in your Android App on a different thread. An easy to use method is an Intent Service.
Web Service:
This is often the most confusing part. A Web Service is simply some entry point for clients attempting to access the Web Server. My explanation here might different slightly when using RoR, but the same idea applies. Notice above that the target URL was www.example.com/webservice.php. The web service is literally the PHP code that exists on the Web Server, called webservice.php. In your Android App, when you send data to the target URL using HTTP, the Web Service code will be executed on the server (and also have access to the data that you sent to it). Inside of your Web Service code, you will basically be extracting the data (which is in some format like JSON), grabbing the necessary parts, and then doing something with it. In this case you will most likely be querying the database. In PHP it is easy to write code that connects and queries a MySQL database that is also running on the server. When the response of the database is retrieved by the Web Server, you can send it back to the Android App. Just as before, remember, there is no magic going on. All of these ideas are implemented by writing some code.
Main ideas to research:
Ruby on Rails web service
How to access a MySQL database using Ruby on Rails
MySQL Database:
This is where you will store the data on the Web Server. I am not going to go that in depth here because this is just going to require you doing a lot of reading up on how to set up a MySQL database on a web server. It is also important that you learn how to create the appropriate queries such as SELECT, INSERT and so forth.
Main Ideas to research:
How to setup a MySQL database on a web server
If you need any clarification, let me know!
I am developing an android dashboard app to display various charts.
I am having a local SQLLitedatabase in my application which contains all the values to be displayed.
But I want that whenever my app loads my db should get refreshed by hitting a web server if data connection is ON or else it should display the charts with the local db in offline mode.
Can I update my db using the JSON parser provided by the Android API?
Please suggest the best protocol for this
Yes you can do that. For network related queries you can use the Volley library. That will be good try that one.
clicke here for Tutorial how to use the Volley.
I'm creating an Android application that requires the following:
Data from RSS feed gets sent to phpMyAdmin each day
Android app goes to phpMyAdmin and gets data from table containing RSS data
App makes a decision and does other processing based off the data
The goal is to get data from a website to the database, for the app to use.
I created an RSS feed from the following site http://www.feed43.com
Now that I have my feed set up, I need to parse and send it to the table in phpMyAdmin. The thing is, how do I get the data from the feed to phpMyAdmin? After looking around on Google I've hit a lot of dead ends.
Does anyone have experience with this, or can recommend some useful pointers? Please help.
Why would phpMyAdmin have anything to do with this? phpMyAdmin is just a web interface for MySQL.
What you actually need is interfacing with the DBMS using SQL statements.
I have offline web page on android tablet.
Is it possible to write android service which will get data from web page when user insert data and submit it, and when android service receive data than it has to save it in text file or db.
Everything is in offline local mode.
You should be carful when using the word Service besides android. People might get a worng idea of what you're taliking about because it has a special meaning for android.
Because a local webpage will submit a post request to a certain URL and your device is actually not the webserver you will fail with that. But you can accomplish your task with a javascript/JSON bridge to your local HTML. See this post to see how.
The idea is to use a click handler which collects the needed data and returns it to the webview by the javascript bridge instead submiting the data to a from submit URL. From java side to WebView you can respond with an JSON object.
To accomplish this you need to have fundamental knowledge about HTML and javascript and understand the use of a WebView.