Android connecting to Java Server - java

I'm new in android studio I'd like to know how can I make requests to a server.
I wanted that in my Android App I sign up an account and my server stores all the users, something simple just to start. The next step that i want is like passing some strings or objects to other users.
How can I do that?
Is recommended to do my Server in Java/Python?
Thank you

I would suggest you first google your queries, since there are many such repositories on GitHub.
First Link when I searched Android CRUD was this
https://github.com/budasuyasa/simple-android-crud
As for Java or Python, all depends on your skill set, what I would recommend is using Spring boot for backend services but you can also use Flask to create Rest services in Python.
Have fun coding

Related

Android : Step for Android connect to Laravel API

I am new in programming. And I would like to ask what is the step to connect Laravel API. Let say I want to build an Android App and I want to connect to the backend that is Laravel but the point is, the backend is not created by me it is created by other developer and I'm totally don't understand in PHP.
So in this situation, what is the step or how to do Android connect with the Laravel?
PS: I have already saw some sample from other article, but the tutorial mostly are build the both Laravel and Android at the same time. So that is quite not same with my situation...
So Hope I can find out the answer from here. Thanks in advance
You can use Retrofit for creating calling API service in your android application.
This is a very good tutorial: https://www.journaldev.com/13639/retrofit-android-example-tutorial.
For Laravel API, you can follow tutorial: https://www.toptal.com/laravel/restful-laravel-api-tutorial.
The very first step to interacting with a remote REST API is to have an understanding of what the expected request and response data is. This can typically be found in the documentation of the REST API you're trying to access. In this case, since it has been created by another developer, you should ask them for the docs.
After you've gotten a decent understanding of the API, you can use one of several HTTP client libraries for Android such as Retrofit to send requests and receive responses from the API.
Note: It is not necessary to understand the API's code, only the REST endpoints and the request/response schema. A good example of API documentation can be found here

How to get Data for your app from your Server?

So I want to know the basic idea of how a app can get its data from your own server. We use APIs to get data from other data sources like OpenWeather . But now if we want to create our own source how would you do that? I just want to know the basic idea not the code.
Thanks
Basic idea would be:
get a free hosting somewhere (there's a lot of PHP hosting websites with MySQL)
create a simple REST API
get some data into your database (create a simple CMS to add data to the DB)
make your Android app call your website just like you did with the weather API
TL;DR: create your own API

Spring Rest API Confusion

I am exploring the possibility of using a RESTful API as the backend for an Android application.
I previously have simply been using socket programming to have my clients connect to server application but since I intend to develop a web application (with the admin functionalities for the android app) I figured this may be a good option.
My backend will be required to pull data from a nosql database and run a machine learning algorithm periodically on the data. The android app will, amongst other things, query the results of the computations and provide additional information to the algorithm.
Is it possible for me to use Spring to expose some of the application functionality through a REST API while still having other functions and tasks running in the background? Basically, can I design an application that will query multiple web services and perform various scheduled computations and query and expose only some of those functions through an API ?
Am I approaching this completely the wrong way?
Your approach sounds fine to me. Your REST API could just call internal backend methods as needed and return their output as JSON or XML formatted data.
I recommend you, if you haven't already looked at them, to go through the Spring "Getting Started" guides for building a RESTful web service and scheduling tasks.
On the Android side I'd recommend you to look into Retrofit.

How Connect to Remote MySQL server through Android App via JDBC

I first successfully connected via JDBC to a remote MySQL server with a Java program. That I understand how to do. My goal is do the same thing with an Android application and display data from a remote MySQL server.
Question 1 Can someone explain the process outline to do this via Android ? (I am new to Android and am a little stronger with Java, could use a little guidance).
Question 2 I found this tutorial on javatutorialpoint.com titled: Android MySQL Client but it wants me to use the SOAP API. Not sure why, if someone could explain.
Not asking for it to be done for me. I just want someone to outline the main steps in order to make it happen. Just the process that needs to occur is all I am asking.
Question #1:
I stumbled upon this link some time ago:
http://docs.oracle.com/cd/E17076_02/html/installation/build_android_jdbc.html
(Disclaimer: I haven't read the whole tutorial myself)
It tells you what's needed for getting the MySQL connector to work with Android.
Basically, from what I know, the standard MySQL connector for Java, doesn't work out of the box for Android. You'll need to build it on your own.
After building the connector, you can include it in your Android project, precisely the same way as you do in a normal Java project.
Your Question #2:
SOAP is a mere layer of abstraction, for not working directly on the database. If you use a layer like SOAP, you can swiftly change your database layer without affecting much of the communication from-and-to the Android app.
You can use the same methods in Android you used in Java (Android is written in Java, after all, and you are able to use the majority of its libraries in android). However, be careful with doing so.
It would probably be better from a security standpoint to set up a web service to communicate with the database, rather than you allowing your android app to communicate directly with it, which would actually require you to embed your mysql username and password in the app code. A SOAP or RESTful web service could enable your server to communicate with the DB and then serve the data from it to your app.
It's done the same as in Java (Android apps are build in Java unless you're using the NDK).
You don't need SOAP if you only want to get data from a remote DB.
See this question.

Can I run locally and debug a Web App that uses Google API's? [GWT+GAE]

I'm working on a web-app using Google App Engine with GWT, and I need to use Google API's (Google Calendar, Documents and so...).
As I know, I must configure a domain with Google to set my domain as callback of an OAuth Authentication. Am I right?
If so, am I forced to deploy on GAE to test? I mean, I can't run locally because my localhost can't be a valid callback.
Do you know any way to debug locally even using Google API's?
I have recommended to config a DynDNS, but isn't a solution in short term (incompatible router)...
If you use AuthSub instead I don't think you need to register a domain. The user just need a google account.
I have in the past used AuthSub together with Google Docs/Spreadsheet APIs on GAE and also been able to test it locally.
I can unfortunately not give you my code and exact solution (it was a while ago). But one of the samples I used extensively to base my code on was the FetcherServlet, check this code out:
http://code.google.com/p/google-app-engine-samples/source/browse/trunk/retrieving-gdata-feeds-java/src/com/google/appengine/demo/web/FetcherServlet.java?r=122
Also, I guess you might already have read this page (but their FetcherServlet uses OAuth, not AuthSub), so maybe just use it for some background info:
http://code.google.com/appengine/articles/java/retrieving_gdata_feeds.html

Categories