Start a new topic

Wikitude in fragment

Wikitude in fragment


Hello,

I am writing an application which has 3 fragments in one activity with action bar tabs. The other 2 fragments are working fine but the one with wikitude is causing problems.

The architect view lifecycle methods are called from same fragment methods. I tried a couple of things when switching tabs:


Detaching and reattaching fragment -  I works only the first time after that when I detach it and reattach it I get a black screen and messages that current location is not available event though I am setting it. 

Adding and removing fragment - The first time is black screen after that is starts to work but it messes up the styles of my application. Background of all activities becomes black.

Showing and hiding fragment - This one seems to be working at first but when wikitude fragment is hidden its not paused so it continues to use resources. I tried to pause it manually when I hide it and resume it when shown but the whole application crashes on resume.


I read the other thread about fragments, but I don't find solution there. Can you suggest something.

 

Thank you,

Rado

 

Hi Rado,

Setting up the AR-environment takes some time, specially on first start, that does not fit well the "users like to swipe smoothly in a panorama UI".

Anyway - I'm just listing some possible solution to your issue knowing that it's quite hard to remote debug your issue without having the source ;-)


Ensure to properly implement all life-cycle callbacks (e.g. call architectView.onCreate() and onPostCreate() right afterwards in Fragment's super.onActivityCreated(); )

In case you are using FragmentPagerAdapter you may even override the onDestroyItem, so you can avoid the fragment being kicked when uer swipes

You have no more than 3 fragments to page through: Embed the AR-View in center of your fragmentpager if possible so it is always loaded and not destroyed while swiping (since adapter always preloads left/right page)

In case you think of providing the experience also to low-end devices and have performance issues there in conjunction with your fragment-pager you may think of a non-swipe approach and open cam on-demand when user e.g. presses the "AR-View" button in your ActionBar.


Regards,
Andi

Hi Andi,

Thank you for your answer, I managed to resolve almost all of my troubles. The only problem I still have is that when the fragment with architect view is being shown it changes the background of all other fragments to black. I suppose it changes the styles of android application. Can I prevent this from happening?

Thanks,
Rado

Hi again,

This really sounds strange - we do not change layout settigns of parent ViewGroup. 
On which devices do you have this behavior? In case you are using an Android 4.x device could you please also check if disabling force GPU rendering changes anything.

Hope that helps.

Cheers,
Andi

Hi,

I am testing it on Nexus S with 4.1 and this option is disabled throughout the whole time. After I saw you post I ran it on Galaxy Note with 4.0.4. Disabling the option there has a positive effect, the background is not altered. I don't have more android devices at hand to test it on. Is the problem related to the android version or it is more device specific?

Thanks,
Rado

Hi Rado,

Sorry for late response. Issue is a combination of both ;-)
Usually the GPU rendering does not cause any issue in the SDK, but inproper life-cycle handling may cause openGL context not being freed causing unexpected UI troubles on Android 4.x devices.

Cheers,
Andi
Login or Signup to post a comment