Android app communication with web server? - java

I am coming from java based web application background where client is thin client i.e. browser and all UI pages(HTML,CSS,JS) along with
data comes from server. But with recent read on net about android based mobile apps and based on Q/A on stack overflow came with this understanding
Android app with backend(where data is fetched from server) is like two application communicating with each other on http. When I say two app , these
are one on mobile which is java(android) application and second is on server which is generally exposed through web services which can be in any language
like java/dot net. Is it correct ?
If yes I have one doubt when comparing it with java server based web app This is in regard of where UI pages . In web application,
UI views are returned from server in the forms of HTML. But I am confused where UI pages resides in android app. Is it generally on client side(all ui pages
are downloaded with app . With different events app serves the UI from client side itself but data comes from server) or they are served from server ?
If from server are they served again as HTML or there is some other format that android better gels with ?
May be android app generally should not expect any UI pages from server which means downloaded app should have all UI pages with it.

I think the UI is still on the client while the content for filling of the UI is from the server. This content is transported in HTTP(s) protocol, therefore in HTML format as you said. But one can use other protocols to get the response from the server I guess.

Related

Oracle MAF : Supports for Web application?

I know that, Oracle MAF is used to develop hybrid mobile application for both Android and IOS device with native look and feel.
I have created REST Web Service and deployed on the WebLogic server as described in this tutorial and also created mobile client app for Android device with use of Android SDK. It is running successfully on Android Device.
Now, It is possible to run mobile client on server (May be WebLogic, Glassfish, Tomcat) so that it can be accessed as a Web Version (Web Application).
As a try, I have zipped mobile client application as a war file and also deployed on Tomcat and WebLogic but without success.
Below is the error message which I got when accessing the home URL from WebLogic server.
Error 403--Forbidden
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.4 403 Forbidden
The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.
Share yours ideas to resolve this issue if you have any, it will help current and future MAF developers.
MAF creates application that deploy and run on the device.
ADF creates server side applications that can be accessed from the browser on a mobile device.
Two separate architectures addressing two separate needs.
No it's not possible. Zipping the .apk (Android) or .ipa (iOS) file will not make it a web application. Those files are also containers but they contain native code.
Use Oracle ADF for web applications.

Integrate a finished web service in a Android application

I don't know if the correct term is "integrate" or "connect" a finished web service in a android application. I mean,
Is there any possibility to "integrate" a finished RESTful Web Service in a Android application, which I have not developed, yet.?
Otherwise,
Are there some steps to develop a RESTful web service which I need to use from a Android application?
The last question is asked because I don't know if the first step is to finish my RESTful Web Service and then integrate it in my android application or or developing the RESTful web service and the android application at the same time.
In any case, how I can do it well? I need help to organise my mind
You will need three things:
Client(your app)
Server
Database
Lets say you have to create a login service for your app. Then your steps should be like given below:
Create a login form with android UI.
Get username and password from Edit Texts in strings.
Send these credentials to server(via http reqest).
At client side read response from url via input stream.
At the server side, use a server side technology in which you are familiar with.(If you are not familiar with any server side tech. I strongly recommend you php.)
Select/update/compare (Whatever you want) in data base and return response as a json string.
You can use server on your system. I suggest to use XAMPP(cross platform apache mysql php perl). As its name says, it includes server+database+php (its local). It will create a local apache server on your machine.
Follow this : XAMPP Tutorial , Working with XAMPP
Here are some nice tutorials of web services with android:
How to connect Android with PHP, MySQL
Using Database from an Android Application

Sync desktop application with android application

I want to raise an event from my Android application to my desktop application which is in Java. Can I do so? If yes, which API to use? Any examples or code snippets?
Both android and desktop applications are clients. Two clients can talk to each other via server or at least initialize their connection via server that is running on pre-defined location (IP address). So, you need some server that allows to do this.
You can probably use (or abuse) some 3rd party servers for this. For example if your desktop application "knows" the phone number it can send SMS via one of available web services. The android application will catch the SMS and take information from its text. You probably can use Skype installed on your machine or email to send messages among applications too. But better way is to develop your own server that exposes RESTful API and use it for the negotiation.

Syncing Android and Server

I don't know what this is called, but it is something like syncing android application and a Web server. Examples are RSS Feeds and Weather Forecast
Does anyone know the concept behind developing application? I mean how do you sync the Android phone with a web server. Is there any programming needed in the server side and the client side(Android)
Are there any programming books that tackles this subject? Thanks.
What should I do to connect to Server from eclipse - Android?
check the whole conversation here
The server should make the data available in a meaningfull parsable format (for machines). For example RSS/XML feeds, etc. Your application should poll frequently and updates the status/screen.

Async data fetching from Java WebService

I'm implementing a client-server GPS application. Client side is a J2ME midlet that sends GPS location via HTTP/XML to a Java Webservice (Tomcat servlet). The servlet stores positions in SQL database. The other client app is a web browser that can login and see the actual position of midlet using Google Maps. This client is written using GWT. All is deployed on the same Tomcat container. Now I'm wondering how to dynamically update current position in webrowser Google Maps of the mobile so that the client can see how the mobile moves. How to do it in GWT - should I create a timer object in GWT client and asynchronously send HTTP request to server for getting the actual positions? Or is there any mechanism in AJAX/GWT to notify client (web browser) about the data update?
Thanks
Dominik
Regardless of all the talk about "push", the standard HTTP model is still one where the client has to ask the server for updates.
In a GWT app, you should use the well-supported Ajax functionality to request small-granular updates (polling, I guess) from the server at regular intervals (5 seconds, maybe?) and use the newly obtained information to update your map info.
There is a detailed article on the GWT incubator web site about Server Push and how to achieve it with GWT. From the article:
Explains Server Push, sometimes known as 'comet', and how you can achieve this with GWT.
Then, if you take a look at the comments, you can find interested related information and open implementations as gwt-comet, GWTEventService ...
I agree with rok.
If your deployment is going to be small enough to be able to support one permanent connection per web browser client go with Server Push/ Hanging RPC/ Long Polling or whatever you want to call it.

Categories