Android Embed(Java)

Download the ARMOD AAR

The first step to enhancing your application is to get our SDK!
We have uploaded ARMOD Framework (0.0.1) to github. You can click here to go to the github page and download our ARMOD AAR. If you think ARMOD is good please give us a star. Thank you!

Import ARMOD AAR

Select your project's app folder, via the context menu Reveal in Finder (Mac) or Show in Explorer (Windows). Place all downloaded AAR files in app/libs/.
Name
Format
Brief
unityLibrary-release
AAR
Main library
ARMODAPI-release
AAR
All API
UnityARCore
AAR
ARCore
arcore_client
AAR
ARCore
ARPresto
AAR
ARCore
unityandroidpermissions
AAR
ARCore

Embed Coding

NDK Build Configure

Back to Android Studio Editor. And Edit build.gradle(Module:YOUR_PROJECT_NAME.app). Append some configre's code.
Adding NDK to androiddefaultConfig block.
build.gradle(Module:ProjectName.app)
build.gradle(Module:ProjectName.app)
1
ndk {
2
abiFilters 'armeabi-v7a', 'x86', 'arm64-v8a'
3
}
Copied!
1
android {
2
...
3
defaultConfig {
4
...
5
//New config
6
ndk {
7
abiFilters 'armeabi-v7a', 'x86', 'arm64-v8a'
8
}
9
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
10
}
11
...
12
}
Copied!
Please set up according to the architecture you need

Dependencies setup

Adding dependencies. You can also use implementation(name:'AAR_FILE_NAME',ext:'aar')to import new dependencies.
build.gradle(Module:ProjectName.app)
build.gradle(Module:ProjectName.app)
1
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
Copied!
1
dependencies {
2
//New dependencies
3
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
4
5
implementation 'androidx.appcompat:appcompat:1.2.0'
6
implementation 'com.google.android.material:material:1.2.1'
7
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
8
implementation 'androidx.navigation:navigation-fragment:2.3.1'
9
implementation 'androidx.navigation:navigation-ui:2.3.1'
10
testImplementation 'junit:junit:4.+'
11
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
12
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
13
}
Copied!
Sync your gradle!
1
> Task :prepareKotlinBuildScriptModel UP-TO-DATE
2
3
BUILD SUCCESSFUL in 762ms
Copied!

Implement Callback

You must implement all abstract methods. These are callbacks of the ARMOD SDK.

Launch AR

Create a new Activity call it ARView. Then extends AbstractARMODActivity and implementing abstract method onCreateUI
Go to , adding the ARView activity in application block.
1
<activity android:name=".ARView" android:screenOrientation="fullSensor" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false" android:process=":Unity"
2
android:label="@string/app_name">
3
</activity>
Copied!
Add some code to onCreateUI function.
1
//Init sdk
2
initARMOD("JSON Config",MainActivity.class);
3
4
//Add UI from layout file
5
LayoutInflater tmp_Inflater = getLayoutInflater();
6
View tmp_ARView = tmp_Inflater.inflate(R.layout.arview_main,null);
7
getARMODFrameLayout().addView(tmp_ARView);
Copied!
Add new function to stop the ARView.
1
public void CloseARView(View _v){
2
unloadAndHideARMOD();
3
}
Copied!
Back to MainActivity.java, adding a new function to call the sdk.
1
public void ARLauncher(View _v){}
Copied!
Using the Intent to start a new activity.
1
Intent intent = new Intent(this, ARView.class);
2
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
3
startActivityForResult(intent, 1);
Copied!

Summary

More infomation of Native API you should read Android Native Calls Protocol API. We uploaded the sample project of this Native Android (Java) project to github. At now you can download our source project from github.
Last modified 1mo ago