|
14 | 14 | #include "Misc/CommandLine.h" |
15 | 15 | #include "Engine/Engine.h" |
16 | 16 |
|
17 | | -#if PLATFORM_ANDROID |
18 | | -#include "Android/AndroidJNI.h" |
19 | | -#include "Android/AndroidApplication.h" |
20 | | - |
21 | | -// Helper function to get command-line arguments from Android Intent extras |
22 | | -// Calls the AndroidThunkJava_GetIntentCommandLine() method added via UPL |
23 | | -FString GetIntentCommandLineFromAndroid() |
24 | | -{ |
25 | | - FString Result; |
26 | | - |
27 | | - if (JNIEnv* Env = FAndroidApplication::GetJavaEnv()) |
28 | | - { |
29 | | - // Get GameActivity class |
30 | | - jclass GameActivityClass = FAndroidApplication::FindJavaClass("com/epicgames/unreal/GameActivity"); |
31 | | - if (GameActivityClass != nullptr) |
32 | | - { |
33 | | - // Find our custom method: AndroidThunkJava_GetIntentCommandLine() |
34 | | - jmethodID GetIntentCmdLineMethod = Env->GetMethodID( |
35 | | - GameActivityClass, |
36 | | - "AndroidThunkJava_GetIntentCommandLine", |
37 | | - "()Ljava/lang/String;" |
38 | | - ); |
39 | | - |
40 | | - if (GetIntentCmdLineMethod != nullptr) |
41 | | - { |
42 | | - // Get the GameActivity instance |
43 | | - jobject GameActivityObj = FAndroidApplication::GetGameActivityThis(); |
44 | | - if (GameActivityObj != nullptr) |
45 | | - { |
46 | | - // Call the method |
47 | | - jstring JavaResult = (jstring)Env->CallObjectMethod(GameActivityObj, GetIntentCmdLineMethod); |
48 | | - if (JavaResult != nullptr) |
49 | | - { |
50 | | - // Convert Java string to FString |
51 | | - const char* JavaChars = Env->GetStringUTFChars(JavaResult, nullptr); |
52 | | - Result = FString(UTF8_TO_TCHAR(JavaChars)); |
53 | | - Env->ReleaseStringUTFChars(JavaResult, JavaChars); |
54 | | - Env->DeleteLocalRef(JavaResult); |
55 | | - } |
56 | | - } |
57 | | - } |
58 | | - |
59 | | - Env->DeleteLocalRef(GameActivityClass); |
60 | | - } |
61 | | - } |
62 | | - |
63 | | - return Result; |
64 | | -} |
65 | | -#endif |
66 | | - |
67 | 17 | void USentryPlaygroundGameInstance::Init() |
68 | 18 | { |
69 | 19 | Super::Init(); |
70 | 20 |
|
71 | 21 | FString CommandLine = FCommandLine::Get(); |
72 | 22 |
|
73 | | -#if PLATFORM_ANDROID |
74 | | - // On Android, merge Intent extras into command line |
75 | | - // Intent extras are passed via: adb shell am start -n <package>/<activity> -e test crash-capture |
76 | | - FString IntentCommandLine = GetIntentCommandLineFromAndroid(); |
77 | | - if (!IntentCommandLine.IsEmpty()) |
78 | | - { |
79 | | - UE_LOG(LogSentrySample, Display, TEXT("[SentryPlayground] Intent command line: %s"), *IntentCommandLine); |
80 | | - // Prepend Intent args so they take precedence over default command line |
81 | | - CommandLine = IntentCommandLine + TEXT(" ") + CommandLine; |
82 | | - } |
83 | | -#endif |
| 23 | + UE_LOG(LogSentrySample, Display, TEXT("Startin app with commandline: %s\n"), *CommandLine); |
84 | 24 |
|
85 | 25 | // Check for expected test parameters to decide between running integration tests |
86 | 26 | // or launching the sample app with UI for manual testing |
|
0 commit comments