Add SDK to your project

  • Download the SDK from https://s3.amazonaws.com/fpcdn/static/mobile/FloorplannerARViewer.Android.v1.0.zip
  • With your project open click on File -> New -> New module and select Import .JAR/.AAR Package. In the next screen select the supplied floorplanner_ar_viewer.aar file in File name and click Finish.
  • Add the following to the dependencies of the build.grade file of your project:
    dependencies {
      // ... other dependencies ...
        
      implementation project(':floorplanner_ar_viewer')
      implementation 'com.google.ar:core:1.2.0'
      implementation 'com.squareup.okhttp3:okhttp:3.9.1'
        
      // ... other dependencies ...
    }
    

Using the AR viewer

Permissions

Using the SDK the app will automatically add the required permissions to the AndroidManifest.xml.

Launching the activity

import com.floorplanner.arviewer.ARViewer;

class MyActivity : AppCompatActivity {
    void launchARView() {
        ARViewer.launch(
            this,
            "63fb5e8a8b1a611902d77c642e06215d668b347e", // assetId
            "Drift Coffee Table" // title
    }
}

Customizing the ARViewer

Before showing the ARViewer you can customize the way the viewer looks by supplying an extra config object that inherits from ARViewer.UIConfig and overrides some methods:

ARViewer.UIConfig config = new ARViewer.UIConfig() {
    
    // This will set the background color of the middle button
    @Override
    public int getMainColor() {
        return Color.rgb(0,0,255);
    }
    
    // This will set the color of the plane that's shown to the
    // user to indicate the detected floor
    @Override
    public int getPlaneColor() {
        return Color.rgb(0, 255, 0);
    }
}

ARViewer.launch(this, "63fb5e8a8b1a611902d77c642e06215d668b347e", "Drift Coffee Table", config);

create a custom button

The following example changes the middle button to a custom button. The same can also be achieved for the left and right buttons by overriding the getLeftAction, getLeftText getLeftIcon and handleLeftAction for the left button and overriding the getRightAction, getRightText getLeftIcon and handleRightAction for the right button.

ARViewer.UIConfig config = new ARViewer.UIConfig() {
    
    // Returns ARViewer.UIAction.CUSTOM to indicate the viewer should call 
    // handleMainAction when the button is pressed.
    @Override
    public ARViewer.UIAction getMainAction() {
        return ARViewer.UIAction.CUSTOM;
    }

    // This function should return the id of a string defined in string.xml
    @Override
    public int getMainText() {
        return R.string.add_to_cart;
    }

    // This function should return the id of a drawable to use as an icon 
    // for the button
    @Override
    public int getMainIcon() {
        return R.drawable.shoppingcart;
    }
    
    // This method will be called when the user presses the middle button When
    // it's action is CUSTOM
    @Override
    public void handleMainAction(ARViewerFragment arFragment) {
        // ... Handle click ...
    }
}

ARViewer.launch(this, "63fb5e8a8b1a611902d77c642e06215d668b347e", "Drift Coffee Table", config);