I’ve been trying to figure out how to add an Android activity to GameActivity in Unreal 5.4. the only way I could find online to extend GameActivity is through using the gameActivityClassAdditions tag in the APL file.
APL.xml:
<extensions>
<buildGradleAdditions>
<insert>
android {
compileSdkVersion 34
}
</insert>
<insert>
dependencies {
implementation('com.google.guava:guava:31.1-android')
implementation('androidx.health.connect:connect-client:1.1.0-alpha07')
}
</insert>
</buildGradleAdditions>
<gameActivityImportAdditions>
<insert>
import androidx.health.connect.client.HealthConnectClient;
import androidx.health.connect.client.PermissionController;
import androidx.health.connect.client.records.StepsRecord;
import androidx.health.connect.client.request.ReadRecordsRequest;
import androidx.health.connect.client.time.TimeRangeFilter;
import java.time.ZonedDateTime;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
</insert>
</gameActivityImportAdditions>
<gameActivityClassAdditions>
<insert>
<![CDATA[
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Display a simple Toast message on screen when the app starts
Toast.makeText(this, "App Started - onCreate() called", Toast.LENGTH_LONG).show();
}
@Override
protected void onResume() {
super.onResume();
// Display another Toast message when the app resumes
Toast.makeText(this, "App Resumed - onResume() called", Toast.LENGTH_LONG).show();
}
]]>
</insert>
</gameActivityClassAdditions>
<manifestAdditions>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.health.READ_STEPS" />
<!-- Add the intent filter -->
<application>
<activity android:name="com.yourcompany.TAMA.GameActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW_PERMISSION_USAGE"/>
<category android:name="android.intent.category.HEALTH_PERMISSIONS"/>
</intent-filter>
</activity>
</application>
</manifest>
</manifestAdditions>
</extensions>
I’ve put some log messages to display when it’s created from GameActivity. However, I’m getting this error when building the apk:
GameActivity.java:2688: error: method onCreate(Bundle) is already defined in class GameActivity
So it looks like I’m not able to redefine any methods in GameActivity, is there a way to make this work or a better way to do this? I’m a beginner and grasping at straws at this point