Download the Android SDK from https://developers.wakingapp.com/#download

Integration with Android Studio

General information

The WakingApp Viewer SDK for Android contains the following architectures:

  • armeabi-v7a
  • arm64-v8a

The SDK requires a minimum API level of 22 (Android 5.1).

Adding the AAR to your Android Studio Project

Step 1: Change to project view

Step 2: Drag & Drop the wakingapp.aar file onto the libs folder in Android Studio.

Step 3: Open the app's build.gradle file

Step 4: Add the following block to build.grade

// Add to import our AAR files
repositories {
    flatDir {
        dirs './libs'
    }
}

Step 5: Add the following implementations to the dependencies block

implementation(name:'wakingapp', ext:'aar')
implementation 'com.google.ar:core:1.6.0'

For a new project the build.gradle file will be similar to the image below:

Make sure to sync the project after these changes-

Step 6: Edit your AndroidManifest.xml file

Make sure you have specified the activity's orientation so that camera rendering can adjust in runtime.
Edit the activity that derives from ARActivity (in this case- MainActivity) to contain a key for the orientation, e.g:

<activity android:name=".MainActivity" android:configChanges="orientation|screenSize">

Add the ARCore optional usage tag inside the Application block.
This allows the SDK to query if the device supports ARCore or not.

<application>
                
<!-- ARCORE -->
<meta-data android:name="com.google.ar.core" android:value="optional" />

</application>

Step 7: Go to your MainActivity and derive from ARActivity

import com.wakingapp.wa3dlib.ARActivity;


public class MainActivity extends ARActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

Compile and install the app on an Android phone or tablet.
The Camera view should be rendered in the background

Loading a project

From local storage (Compiled with the app)

Create a Directory inside src/main and name it 'assets'

📘

An exported project file for testing the integration can be downloaded from here.

Drag & Drop the project file onto the assets folder-

Add the following line inside the onCreate function, to load the project-

loadProject("test.wa");

If you've used the test project - scan the image below to see a model with animation:

You can unload the currently loaded project by calling the unloadCurrentProject function available in ARActivity.

unloadCurrentProject();

From A Publish server (Downloading at runtime)

Edit your app's manifest to include the following permissions (prior to the application tag):

<!-- required permissions for Publish Server Manager -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Go to your MainActivity and import the following package:

import com.wakingapp.publish.*;

Edit the onCreate function to add a listener to the publish-server-manager

// initialize the publish-server-manager
WAPublishServerManager.getInstance().initWithContext(this);

// listen to events
WAPublishServerManager.getInstance().setPublishServerListener(new WAPublishServerDelegate() {
  @Override
    public void downloadStarted(String s) {
    //Happens when the download started, meaning the request was successful
  }

  @Override
    public void downloadProgress(String url, float progress) {
    final int p = (int) (progress * 100);
    final String pString = p + "%"; // this url's download progress
  }

  @Override
    public void downloadComplete(String url, String localPath, boolean fromCache) {
    if (fromCache) {
      //Project is already cached
    } else {
      //Project was downloaded and is now cached on the device
    }

    //load the project
    loadProject(localPath);
  }

  @Override
    public void downloadError(String url, String errorMessage) {
    // There was a problem downloading the project
  }

  @Override
    public void searchComplete(WAPublishServerSearchResults.WAPublishServerProject[] waPublishServerProjects) {
    // Happens when a search (by keyword) returns
  }

  @Override
    public void searchError(String errorMessage) {
    // Happens when there was an error searching
  }
});


WAPublishServerManager.getInstance().downloadOrLoadProject("https://wa.mg/BgQaHt-VV");

The Project link at https://wa.mg/BgQaHt-VV can be downloaded through the SDK.
It is a SLAM based project with some logic in it.
Move your devices slowly, in order to scan a surface - upon tapping the device's screen the model will 'snap' to the found surface, tapping it again will cause it to move along the found surfaces.

The first time the app runs, it will download and cache the project on the device.
From there on, unless you delete the app's cache or remove and reinstall it on a device - The app will load the file from cache.

This will only work on ARCore supported devices.

You can check if a project loaded successfully by overriding ARActivity's onProjectLoaded function-

@Override
protected void onProjectLoaded(ProjectLoadSuccessState loadSuccessState, String projectName, String projectFilePath, String trackType)
{
  if(loadSuccessState == ProjectLoadSuccessState.LoadSuccess) {
    //Project was loaded
  }
  else if(loadSuccessState == ProjectLoadSuccessState.LoadFailed_ProjectNotCompatible) {

  }
  else if(loadSuccessState == ProjectLoadSuccessState.LoadFailed_ARCoreNotSupported) {

  }
  else if(loadSuccessState == ProjectLoadSuccessState.LoadFailed_UserDeclinedARCoreInstall) {
  }
}

You can delete the cache (containing all cached project files downloaded so far) by calling:

WAPublishServerManager.getInstance().deleteCache();

You can also override ARActivity's onSceneLoaded function to listen on scene-loading events.
This can be useful for image-target based projects, where you want access to the actual bitmap being tracked:

@Override
protected void onSceneLoaded(final boolean loadedSuccessful, Bitmap targetImage)
{

}

Finally, the MainAcitivity.java file in this example contains the following code:

package com.wakingapp.test;

import android.graphics.Bitmap;
import android.os.Bundle;

import android.view.Window;
import android.view.WindowManager;

import com.wakingapp.wa3dlib.ARActivity;
import com.wakingapp.publish.*;


public class MainActivity extends ARActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //Hide top bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_main);



        // initialize the publish-server-manager
        WAPublishServerManager.getInstance().initWithContext(this);

        // listen to events
        WAPublishServerManager.getInstance().setPublishServerListener(new WAPublishServerDelegate() {
            @Override
            public void downloadStarted(String s) {
                //Happens when the download started, meaning the request was successful
            }

            @Override
            public void downloadProgress(String url, float progress) {
                final int p = (int) (progress * 100);
                final String pString = p + "%"; // this url's download progress
            }

            @Override
            public void downloadComplete(String url, String localPath, boolean fromCache) {
                if (fromCache) {
                    //Project is already cached
                } else {
                    //Project was downloaded and is now cached on the device
                }

                //load the project
                loadProject(localPath);
            }

            @Override
            public void downloadError(String url, String errorMessage) {
                // There was a problem downloading the project
            }

            @Override
            public void searchComplete(WAPublishServerSearchResults.WAPublishServerProject[] waPublishServerProjects) {
                // Happens when a search (by keyword) returns
            }

            @Override
            public void searchError(String errorMessage) {
                // Happens when there was an error searching
            }
        });


        WAPublishServerManager.getInstance().downloadOrLoadProject("https://wa.mg/BgQaHt-VV");
    }

    @Override
    protected void onProjectLoaded(ProjectLoadSuccessState loadSuccessState, String projectName, String projectFilePath, String trackType)
    {
        if(loadSuccessState == ProjectLoadSuccessState.LoadSuccess) {
            //Project was loaded
        }
        else if(loadSuccessState == ProjectLoadSuccessState.LoadFailed_ProjectNotCompatible) {

        }
        else if(loadSuccessState == ProjectLoadSuccessState.LoadFailed_ARCoreNotSupported) {

        }
        else if(loadSuccessState == ProjectLoadSuccessState.LoadFailed_UserDeclinedARCoreInstall) {
        }
    }

    @Override
    protected void onSceneLoaded(final boolean loadedSuccessful, Bitmap targetImage)
    {
        
    }
}