Hi!
I’m trying to port admob to flax, but I don’t know how to get the android activity.
I was able to initialize the sdk but I can’t display the banner because it needs the activity.
How should it be done? I’m using firebase c++ sdk
You could use GameCooker.PostProcessFiles
event to customize output activity from <game_output>/Android/app/src/main/java/com/flaxengine/GameActivity.java
(https://github.com/FlaxEngine/FlaxEngine/blob/master/Source/Platforms/Android/Binaries/Project/app/src/main/java/com/flaxengine/GameActivity.java).
To get current game cooking info use GameCooker.CurrentData
so you will get that output path info in that event.
Sorry my mistake in explaining what I am looking for.
My intent is not to modify the activity directly but to get the reference at runtime.
In investigating I noticed that I could use
AndroidPlatform::GetApp()->activity->clazz;
But when I try to call the method from a script I get the error
name followed by ‘::’ must be a class or namespace name
This is probably a noob mistake but unfortunately c++ is not part of my tools of the trade because I mainly use c#.
Anyway, I include both the header
#include "Engine/Platform/Android/AndroidPlatform.h"
either add the respective module in the Game.Build.cs file
options.PublicDependencies.Add("Platform");
Actually this work fine for me, of course ensure to use that code on Android compilation only:
#if PLATFORM_ANDROID
#include "Engine/Platform/Android/AndroidPlatform.h"
#include "Engine/Main/Android/android_native_app_glue.h"
#endif
void Func()
{
#if PLATFORM_ANDROID
auto a = AndroidPlatform::GetApp()->activity->clazz;
#endif
}
I’ll add used internally android_native_app_glue.h
file to be distributed with the engine sources.