I have very little experience with c++ or java and I want to make an Android app with Unreal Engine 5.3, which can either scan or be opened by scanning a QR Code and do something with the Information stored in the QR Code.
At first I wanted to use the QR Reader plugin by etodanik to be able to scan QR Codes, but whenever I try to add it, Unreal says it "could not be compiled. Try rebuilding from source manually." and I was unable to get around that.
Then I added an intent filter to AndroidManifest.xml via project settings:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="citylens" />
</intent-filter>
That made it so the app starts when a QR Code containing "citylens://..." is scanned and supposedly makes the content of the QR Code become the intent.
Then I made this UPL file to add a function to GameActivity.java that should return the intent when called:
<?xml version="1.0" encoding="utf-8"?>
<root xmlns:android="http://schemas.android.com/apk/res/android">
<init>
<log text="IntentService additions rev2 init"/>
</init>
<gameActivityOnCreateAdditions>
<insert>
handleIntent(getIntent());
</insert>
</gameActivityOnCreateAdditions>
<gameActivityOnNewIntentAdditions>
<insert>
handleIntent(getIntent());
</insert>
</gameActivityOnNewIntentAdditions>
<gameActivityClassAdditions>
<insert>
private static String fullUrl = "";
private void handleIntent(Intent intent) {
Uri data = intent.getData();
if (data != null) {
fullUrl = data.toString();
}
}
public native void nativeSendUriToUnreal(String uri);
public static String getIntentData(){
return fullUrl;
}
</insert>
</gameActivityClassAdditions>
</root>
And I added following lines to Build.cs, so the UPL file would work:
string UPLPath = Utils.MakePathRelativeTo(ModuleDirectory, Target.RelativeEnginePath);
AdditionalPropertiesForReceipt.Add("AndroidPlugin", Path.Combine(UPLPath, "IntentService_UPL.xml"));
The getIntentData() function was added successfully, I checked the file, but now I am stuck trying to call it. I added the Android Native plugin and wanted to call the function using that but didn't find a way to. I have disabled proguard, because somewhere someone said that could be a problem. I also tried researching JNI and how to use it in Unreal Engine but I absolutely didn't understand any of it.
Please help me find a way to call that java function from c++ or Blueprint or if you know any other way to access the contents of the QR Code, that would also be great. Thank you for your time.