Skip to content

Commit

Permalink
[Android] Simplified AndroidManifest.xml file and properly finish act…
Browse files Browse the repository at this point in the history
…ivity on back button event.

- Removed redundant attribute "android:label" from activity node; It's already specified for application node.
- Removed nodes irrelevant for the examples: "allowBackup" and "fullBackupContent".
- Invoke ANativeActivity_finish() when back button event is recognized to properly close the application.
  • Loading branch information
LukasBanana committed Aug 5, 2024
1 parent 11caca2 commit 03913a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@

<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application
android:allowBackup="false"
android:fullBackupContent="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:hasCode="false">

<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="android.app.NativeActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:configChanges="orientation|keyboardHidden"
Expand Down
6 changes: 6 additions & 0 deletions examples/Cpp/ExampleBase/ExampleBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#ifdef LLGL_OS_ANDROID
# include "Android/AppUtils.h"
# include <android/native_activity.h>
#endif

#define IMMEDIATE_SUBMIT_CMDBUFFER 0
Expand Down Expand Up @@ -386,6 +387,11 @@ void ExampleBase::Run()
while (LLGL::Surface::ProcessEvents() && !window.HasQuit() && !input.KeyDown(LLGL::Key::Escape))
#endif
{
#ifdef LLGL_OS_ANDROID
if (input.KeyDown(LLGL::Key::BrowserBack))
ANativeActivity_finish(ExampleBase::androidApp_->activity);
#endif

// Update profiler (if debugging is enabled)
if (debuggerObj_)
{
Expand Down

0 comments on commit 03913a8

Please sign in to comment.