ODG R7 Smart Glasses Java Plugin Problem

Hi Fellow Devs,

I’m trying to figure out how to enable stereoscopic view with this device. In documentation it says :

We provide a library: com.osterhoutgroup.api.ext.jar (extension library to change display surface from cloned to extended)that the developer adds as external jar file to their Application project.

There is a method to call : ExtendDisplay.extendWindow(getWindow(), true);

I put that jar file under plugins/android folder and wrote following code :

AndroidJavaClass jc = new AndroidJavaClass("com.osterhoutgroup.api.ext.ExtendDisplay");
jc.CallStatic("extendWindow", true);

Whatever I do, I keep getting method can’t be found error on android devices. Is there a way to call this java method called extendtWindow with this JAR file ?.

I tried to decompile the jar file and access the code :

package com.osterhoutgroup.api.ext;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.SurfaceView;
import android.view.Window;
import android.view.WindowManager;

public class ExtendDisplay
{
  private static final String TAG = "ExtendDisplay";
  private static boolean sWindowSurfaceExtended = false;
  private static boolean sSurfaceExtended = false;
 
  public static void extendSurface(SurfaceView sv, boolean extend)
  {
    if (sv != null)
    {
      sv.extendSurface(extend);
      sSurfaceExtended = extend;
    }
    else
    {
      throw new IllegalArgumentException("SurfaceView is not valid");
    }
  }
 
  public static void extendWindow(Window w, boolean extend)
  {
    if (w != null)
    {
      if (extend) {
        w.setFlags(Integer.MIN_VALUE, Integer.MIN_VALUE);
      } else {
        w.clearFlags(Integer.MIN_VALUE);
      }
      sWindowSurfaceExtended = extend;
    }
    else
    {
      throw new IllegalArgumentException("Window is not valid");
    }
  }
 
  public static void getDisplayMetrics(Context context, Window w, DisplayMetrics outMetrics)
  {
    if (w != null)
    {
      WindowManager wm = (WindowManager)context.getSystemService("window");
      wm.getDefaultDisplay().getMetrics(outMetrics);
      if (sWindowSurfaceExtended) {
        outMetrics.widthPixels *= 2;
      }
    }
    else
    {
      throw new IllegalArgumentException("Window is not valid");
    }
  }
 
  public static void getDisplayMetrics(Context context, SurfaceView sv, DisplayMetrics outMetrics)
  {
    if (sv != null)
    {
      WindowManager wm = (WindowManager)context.getSystemService("window");
      wm.getDefaultDisplay().getMetrics(outMetrics);
      if (sSurfaceExtended) {
        outMetrics.widthPixels *= 2;
      } else {
        throw new IllegalArgumentException("SurfaceView is not valid");
      }
    }
  }
}

Update
I was missing a parameter called Window, this is the last version of my code and still getting errors. This time jni init’d androidjavaclass with null ptr .

AndroidJavaClass cl = new AndroidJavaClass("com.osterhoutgroup.api.ext.ExtendDisplay");
            AndroidJavaClass cw = new AndroidJavaClass("android.app.Activity");         

            cl.CallStatic("extendWindow", cw.Call<AndroidJavaObject>("getWindow") , true);