Adding 'Android' specific code to Actor C++ Code

I’ve added an extern to the LaunchAndroid.cpp code that compiles into the UE4 native library.

extern "C"
{
	bool isPressed(int playerNum, int keyCode)
	{
		//omitted for example sake
		return false;
	}
}

And then I’ve added C++ code to the Flappy Chicken project that I want to have call the extern in the UE4 native library.

// Fill out your copyright notice in the Description page of Project Settings.

#include "TappyChicken.h"
#include "OuyaSDK.h"

#if PLATFORM_ANDROID
extern "C" bool isPressed(int playerNum, int keyCode);
#endif


AOuyaSDK::AOuyaSDK(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
}

bool AOuyaSDK::OuyaGetButton(int32 playerNum, int32 button)
{
#if PLATFORM_ANDROID
	return isPressed(playerNum, button);
#else
	return false;
#endif
}

I’m wondering what the best way is to write ‘Android’ platform code from your Actor C++ code.

Is the PLATFORM_ANDROID check going to compile in the code I’ve added when I publish to the Android platform?

Or is there an alternative way to communicate with native methods from Actor code?

That seems to be the right way to do it because it does detect if I purposely inject an error.

#if PLATFORM_ANDROID
fsdjfdsjkfdsjfdsjkfdsj
#endif

A quick way to check if the mistake is detected:

C:\unreal\UnrealEngine\Engine\Binaries\DotNET\UnrealBuildTool.exe TappyChicken Android Development  C:\ouya-sdk-examples\Unreal\TappyChicken\TappyChicken.uproject  -noxge

The code I posted in the question is correct. Verified it works. My only issue is the BluePrint needed to be wired up properly to actually invoke the event.

You can see a working example by looking at the details of this commit.

https://github.com/tgraupmann/UnrealEngine/commit/34e5b87a24beacc637bb0ddcd31740d6ae63aaef