# How to use Gameactivity.java to add custom Activity to mobile game

**URL:** <https://forums.unrealengine.com/t/how-to-use-gameactivity-java-to-add-custom-activity-to-mobile-game/1974684>\
**Category:** Mobile\
**Tags:** unreal-engine, question\
**Created:** [August 14, 2024, 12:27am UTC](https://forums.unrealengine.com/t/how-to-use-gameactivity-java-to-add-custom-activity-to-mobile-game/1974684 "2024-08-14T00:27:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![frontbutte](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@frontbutte](https://forums.unrealengine.com/u/frontbutte)\
**Post date:** [August 14, 2024, 12:27am UTC](https://forums.unrealengine.com/t/how-to-use-gameactivity-java-to-add-custom-activity-to-mobile-game/1974684/1 "2024-08-14T00:27:04Z")

</div>

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:

```auto
<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:

```auto
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
