0

In my Google Glass app, I have and activity with a CardScrollView.

Like the main Timeline, after ten seconds the screen is off and the activity go to onPause().

However when i tap Google Glass i doesn't see my activity, i see the Home Card (Clock) and if i start again my activity (with "ok, glass + my voice command), the activity starts again (it 's created). I think that previous activity should call to onResume() and this doesn't happend.

So...any idea how can i come back to onResume that activity??

Thanks a lot!

Bae
  • 892
  • 3
  • 12
  • 26

3 Answers3

1

I don't see the same behavior.

If I make a simple app that just shows activity lifecycles events in a textview, either launched by a launcher intent or a voice trigger, I see:

onCreate onStart onResume

when app launches

then if I swipe down or let it time out after ten seconds and then relaunch it by voice command from the ok glass screen, I see

onPause (this happened earlier but I see it now) onStop (same, happened earlier) onRestart onStart onResume

So onResume is getting called.

So I think the answer to your question is onResume does get called when an app goes to sleep and is called back shortly after. If you are seeing differently my only guess is that it is silently crashing or maybe using so many resources that Glass is killing it. You could learn more by adding some strategic log statements into your code. If it is crashing on pause or on stop then fixing the crash will solve your problem. If you share your activity code I can try to help more.

A more complicated solution to have more control of a long running experience for your user is to set up a live card with a service. The documentation for this here is a little confusing: https://developers.google.com/glass/develop/gdk/live-cards so you could just use the code below as an example.

When you run this live card you will find that the screen does not sleep after ten seconds, and that if you swipe down to sleep and tap glass to awake, you will be brought right back to your live card. Maybe that is an experience you are looking for.

https://github.com/mscheel/GoogleGlass-XE16-LowFrequencyLiveCardBasketballScore

Mark Scheel
  • 2,963
  • 1
  • 20
  • 23
  • Hi!See my own answer. The problem was that i had to add `android:immersive="true"` in my activities in the manifest. I need an immersive experience so i don't need to use LiveCard. Thanks for your answer! – Bae Apr 30 '14 at 07:20
  • Are you sure that if you create a basic activity, you wait ten seconds until screen is off and you tap glass, you continue the same activity? I have done that and I see Clock card when tap glass. I don't know why but android:immersive="true" has worked twice and then it didn't work. I am using XE16.11. – Bae Apr 30 '14 at 13:49
  • Yes, I am certain. It works for the basic activity and the live card. – Mark Scheel May 01 '14 at 01:46
0

It may be your Activity is getting GCd (garbage collected) to free up memory once it is paused. You could investigate that by outputting to Log in onDestroy, if you see the log message you know it got destroyed and then it makes a huge amount of sense that it gets recreated.

straya
  • 5,002
  • 1
  • 28
  • 35
  • Hi!See my own answer. The problem was that i had to add `android:immersive="true"` in my activities in the manifest. Thanks for your answer! – Bae Apr 30 '14 at 07:19
0

I had read that when you use the immersive pattern, when screen is off, if you tap and wake up screen, you continue to see your activity. Well, for this you need to add android:immersive="true" in your activities in the manifest.

When screen is off, android call onPause() and onStop. When you tap, android call onRestart() and onStart()

Bae
  • 892
  • 3
  • 12
  • 26