Dear experts, tell me, there is a working application on the GlassFish server (website), and I want to develop a mobile application for Android, to work with this service. How to implement it correctly, what technologies to use?

  • I think that you can link them just like any other web application. The server part is on GlassFish, and the client part is on Android. The client accesses through web requests, as usual (Get, Post). You can use [HttpClient] [1] on Android. Here is [tutorial] [2]. Sorry, I didn’t find normal tutorials on this topic in Russian. But this one is very good and helped me. [1]: developer.android.com/reference/org/apache/http/client/… [2]: vogella.com/tutorials/AndroidNetworking/article.html - Gleb Kuznetsov
  • Thanks for the link. I'm not sure yet, but in my opinion, it should be something like a RESTful web service. I need to get ready data from the server. - b1ack_ange1
  • I imagine this scheme: 1) the service available at mydomain.com/service 2) From the android, I make a request, I request data 3) I accept JSON 4) I write it to the cache (SQLite) 5) I receive data from the database and work with 6) I update the data with a given frequency - b1ack_ange1

2 answers 2

Go here - a simple example of accessing a RESTful web service from Android.

Well, if you, of course, are sure that on the server side the RESTful service will stick out.

If you look deeper, then the server's response should be written to the database (such as a cache), over which the content provider, which gives the cursor, will be added. Accordingly, then all the work is done with this Cursor th. Next, you need to draw a service that monitors the database and service, and from time to time synchronizes the cache.

Something like this.

  • Thank you, this is already warmer! So I am the developer of the site, and I think that I need to "stick out" to communicate with Android. And most likely, I will share xml-files. - b1ack_ange1
  • one
    @ b1ack_ange1 JSON should be thrown out, XML is no longer considered an Orthodox means. Look at the simplest working web service that returns a json string with the current time and date - Barmaley
  • Ok, it’s strange why XML has become in disgrace, well, now JSON mode and we will communicate on it. Thanks for the links. - b1ack_ange1
  • 2
    Because XML is a continuous popabol, parsing its pleasure is below average, it is uneconomical - well, etc. JSON is really convenient - it is directly translated to a Java object. Look in the direction of Google GSON - very good. conveniently - Barmaley
  • So I myself will create these XML, marshalling / unmarshalling and no problems, everything will also be translated directly into a java-object, which I will describe in advance. It’s really hard to work with files with great nesting. I used to use JSONSimple before. - b1ack_ange1

Better tomcat + spring. Spring boot actuator allows you not to install tomcat at all - it will unfold itself in any place where you start the application, and when it is completed, turn off. https://spring.io/guides/gs/actuator-service/

  • Thanks, you can learn. I think he should make friends with the GlassFIsh server. - b1ack_ange1