0
votes

Im very new to Google App Engine development. When integrating GAE with android, is it a good practice to place the code that initializes the endpoints in the Application class ? Meaning, initialize the endpoints once when the app is starting and then refer to those endpoints instances when doing some action with the backend ? My current practice is to create an endpoint instance each time i want to call the backend, but i feel its a little bit heavy and maybe unnecessary.

By "initializing the endpoints" i mean the following code :

    Myendpoint.Builder endpointBuilder = new Myendpoint.Builder(
               AndroidHttp.newCompatibleTransport(),
               new JacksonFactory(),
               new HttpRequestInitializer() {
               public void initialize(HttpRequest httpRequest) { }
               });
    Myendpoint endpoint = CloudEndpointUtils.updateBuilder(endpointBuilder).build();
1

1 Answers

0
votes

I usually create method that creates/gets it if created:

public YourEndpoint getEndpoint() {
    if (endpoint == null) { // initialize .... };
    return endpoint;
}

then have a resetEndpoint() that sets it back to null if you use cookies and you just wanna drop that session.