0

Per the Creating Immersions documentation one can Specify android:immersive="true" for your <activity> element to give immersions focus after a screen sleeps and wakes up.

From my experience, this returns you to the last activity that the user was on before Glass went to sleep, for example: If the user went to ActivityA, then ActivityB, then ActivityC, and Glass goes to sleep, when the user wakes Glass up they're returned to ActivityC.

Is there a way to have the user returned to a specific activity? Say, the same scenario happens as described above, but when Glass wakes up the user is returned to ActivityA?

Thanks in advance, Cole

Cole
  • 676
  • 8
  • 24

1 Answers1

2

Create a member boolean variable like mInitialLaunch in Activity B and C. In onCreate of Activity B and C set mInitialLaunch to true.

At the end of onResume in B and C, set mInitialLaunch to false.

At the start of onResume in B and C, check mInitialLaunch and if it is false (meaning only onResume was called) launch Activity A.

This is a way to game the Activity LifeCycle to do what you want.

If you want more information about the Activity LifeCycle and Glass ...

This is an open source project I created to help students learning Glass and Android basics get up to speed on the Activity LifeCycle:

https://github.com/mscheel/glass-book-activity-lifecycle-explorer

Mark Scheel
  • 2,963
  • 1
  • 20
  • 23
  • Mark, that worked for the most part. There is one edge case in the following scenario when initially starting the app normally with "ok glass, – Cole May 22 '14 at 20:41
  • I'm not sure I follow, but if my answer worked for you accept it or if it helped up-vote it. You might need another question for your edge case and should probably share some code in it. – Mark Scheel May 23 '14 at 04:52