pythonjavaandroidgoogle-cloud-platformgoogle-app-engine

Connecting to Endpoint API on Android Client


I have been reading on creating an android application, and hosting a Google Cloud Endpoints API Backend. Most of the guides that I've seen require you to build the API with Java, but I opted out and made everything using Python.

I am using microservices, and have many API backends to carry out my different task. Now I am having trouble connecting to the API Backend. Most of the guides I've read do it like this...

https://cloud.google.com/appengine/docs/java/endpoints/helloendpoints-android-studio

MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport() ...

MyApi is the name of the api that is deployed and create through the Android Studio app. However, I do not have this because I am deploying my API backend elsewhere.

MyApi is imported from from the package, and all the endpoint functions are brought over with it via

import com.example.myapplication.api.MyApi.MyApi;

How would I connect to my python endpoints api through my android app?


Solution

  • Not 100% sure because I am not used at all to the Python App Engine version but I think that in the AsyncTask you should call the endpoint from your android as explained at the bottom of the example you mention with {android-app-backend} the name of your project.

    MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
        .setRootUrl("https://android-app-backend.appspot.com/_ah/api/");
    

    This work perfectly for me with a java endpoints backend. It should not be different with a python backend, as Android does not "know" in which language the API is written!