سؤال

I'm having serious trouble understanding or finding resources explaining how Google Glass responds to activity lifecycle calls. It seems that if I run a gdk (or normal apk) on glass and the glass prism dims/shuts off that Activity.onStop() sometimes gets called once the prism turns back on. How does google glass's android distribution decide when to call each activity lifecycle method?

هل كانت مفيدة؟

المحلول

I'll try to update this when I have Glass and Eclipse powered up, but you are right that 'weird' things happen when the display goes off. Basically the Activities in your application are 'killed' (not sure if finish() is actually called on them or not).

You can create a Live Card to keep things going with the display off. Your Activity can exit directly to the Live Card when it publishes it and that should avoid finish() getting called, onStop will be called. However, to keep updating the Live Card you should use a Service instead, although it is possible with an Activity in the background, but not recommended.

Or if you are creating an "Immersion" then you can keep the screen on indefinitely with getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top