After a long time searching, I can’t find any instructions on how to provide custom platform specific (Java) code on Android. I succeeded on using jni in my C++ code to access the Java object for the GameActivity class provided by UE4, however, I’d like to either extend that class or provide a custom main activity based on it specific to my game, i.e., I don’t want to change the file inside the engine folder. What’s the proper way to do that? Is there anyway to include additional Java sources in the build process?
I’ve not yet dug into it myself, but the closest thing to an answer I’ve found is the advice to look at the Gear VR and Google VR plugins. Hope this helps, I’m at the start of figuring this out, too.
OK, so I didn’t find a way to create separate classes, but the UPL (unreal plugin language) allows one highly customize the generated GameActivity class. You can find the full documentation of the tags accepted by the UPL in the source file. Here I’ll give an example using my application. Basically I wanted to access the location sensor, so I created a file called LocationService_UPL.xml on the root of the game source (here my game is called Otoshiyori):