问题
I developed based on Android platform, and the initial state of AR session is loaded in fragment form. In order to reset the AR session, a solution found on Google is to update the fragments. At present, the session can be restarted, but the frame cannot be updated, and I cannot realize my own business of following the frame changes. Seek help: 1. Why to update fragments? Frame does not update 2. or do the partners have a better way to reset the AR session
The main idea is to use a cycle timer. If the time exceeds 9 seconds, the AR session will be reset once, but other functions will be executed with each frame update in 9 seconds onUpdateListener method was in onComplete function,but it didnt work within 9 seconds
public void onComplete() {
ArFragment arFragment=(ArFragment) context.getSupportFragmentManager().findFragmentById(R.id.ux_fragment);
ARInitModel.getInstance().setArFragment(arFragment,imageView,R.raw.andy,textView);
ArSceneView senceView = arFragment.getArSceneView();
Scene scene = senceView.getScene();
Scene.OnUpdateListener onUpdateListener=frameTime -> {
System.out.println("onUpdateListener ========================");
};
scene.addOnUpdateListener(onUpdateListener);
}
public static void ReplaceFragment(ConstructNode constructNode){
ArFragment arFragment = new AugmentedImageFragment();
context.getSupportFragmentManager().beginTransaction()
.replace(R.id.ux_fragment,arFragment).commit();
System.out.println("arFragment ReplaceFragment========="+arFragment.getId());
}
来源:https://stackoverflow.com/questions/58995749/how-to-reset-or-restart-the-arcore-sessio