Android SDK from API Engine missing Android Context argument in init()

I created a new host on API Engine and download the autogenerated Android SDK. When I try to run Service.init() on Android I get an exception saying the Android Context needs to be passed to init(context, appid, appsecret, appver). I modified it to pass the Android Context when I run Service.init(getApplicationContext()) and it seems to work alright now.

Im using this
Backendless.initApp(getApplicationContext(), Defaults.APPLICATION_ID, Defaults.SECRET_KEY, Defaults.VERSION );

and works fine

What I mean is the autogenerated code isn’t complete. Today I downloaded the Android SDK autogenerated from my new API engine service and this is the code I got:

public static void initApplication()

{

    Backendless.setUrl( FurusatoKanriService.BACKENDLESS_HOST );

    Backendless.initApp( FurusatoKanriService.APP_ID, FurusatoKanriService.SECRET_KEY, FurusatoKanriService.APP_VERSION );

}

so I added Context manually and it works.

Thanks, Simon. We will look into it.

Mark

Autogenerated code is correct.

this lines of code:

Backendless.setUrl( FurusatoKanriService.BACKENDLESS_HOST ); 
 

 Backendless.initApp( FurusatoKanriService.APP_ID, FurusatoKanriService.SECRET_KEY, FurusatoKanriService.APP_VERSION ); 

let you to make calls from any enironment (except Android).
And you have the opportunity to immediately try to make an invocation even from plain java class (main method).
For android environment you should use the additional argument “context”.

Yes, we have already added the comment to codegeneration. (it will appear in next release).
Thanks.

It makes sense now, in its default autogenerated form it’s meant as a standard Java SDK but if you want to use it on Android you need to use the context argument (which I already did myself and it works). Perhaps adding a comment in the autogenerated code that notifies people they need to do that if they’re on Android would be a good idea. Thanks.