4

I was developing an app for Google glass and i was facing a problem with my activity. They ended when i didn't interact with them for 7 to 10 seconds. After the screen turned off and i tapped my glass to wake it up again, my activity would disappear and i was on ok glass Screen.

I searched a lot but couldn't find any solution to this. Then i came across this android:immersive attribute in Activity in AndroidManifest.xml file.

After using android:immersive="true" in my activity (AndroidManifest.xml file). My activity stays alive even after screen is timed out and my activity resumes when i tap the glass touchpad. Its behaviour is how i imagined the default behaviour.

So i was wondering what is android:immersive attribute and why isnt there any documentation regarding it? Also is this attribute only available only in the GDK ?

I am attaching logs that were generated by activity life cycle so that people can have a better understanding.

//LOGS GENERATED WHEN android:immersive="false" or NOT USED  

01-30 11:58:51.433: E/LifeCycle(5643): OnCreate()
01-30 11:58:51.433: E/LifeCycle(5643): onStart()
01-30 11:58:51.441: E/LifeCycle(5643): onResume()
01-30 11:59:05.566: E/LifeCycle(5643): onPause()
01-30 11:59:05.574: E/LifeCycle(5643): onSaveInstanceState()
01-30 11:59:05.581: E/LifeCycle(5643): onStop()
01-30 11:59:11.511: E/LifeCycle(5643): onRestart()
01-30 11:59:11.511: E/LifeCycle(5643): onStart()
01-30 11:59:11.535: E/LifeCycle(5643): onResume()
01-30 11:59:11.597: E/LifeCycle(5643): onPause()
01-30 11:59:11.988: E/LifeCycle(5643): onSaveInstanceState()
01-30 11:59:11.988: E/LifeCycle(5643): onStop()



//LOGS GENERATED WHEN android:immersive="true"

01-30 11:50:41.995: E/LifeCycle(4929): OnCreate()
01-30 11:50:41.995: E/LifeCycle(4929): onStart()
01-30 11:50:41.995: E/LifeCycle(4929): onResume()
01-30 11:50:56.324: E/LifeCycle(4929): onPause()
01-30 11:50:56.347: E/LifeCycle(4929): onSaveInstanceState()
01-30 11:50:56.347: E/LifeCycle(4929): onStop()
01-30 11:51:09.144: E/LifeCycle(4929): onRestart()
01-30 11:51:09.144: E/LifeCycle(4929): onStart()
01-30 11:51:09.167: E/LifeCycle(4929): onResume()
Sheraz Ahmad Khilji
  • 8,300
  • 9
  • 52
  • 84

1 Answers1

3

"Flag declaring this activity to be 'immersive'; immersive activities should not be interrupted with other activities or notifications." from http://developer.android.com/reference/android/R.attr.html#immersive

The weird thing is that this flag has been available since API level 11, but the "immersive mode", which is an enhanced fullscreen mode, has only been added in API level 19.

TomTasche
  • 5,448
  • 7
  • 41
  • 67
  • Thanks Tom. Another thing that i was concerned was the different ways in which the activity was behaving depending upon this flag value true or false. Do you have any idea why is that ? – Sheraz Ahmad Khilji Jan 30 '14 at 11:47
  • 1
    It sounds like this flag tells the system to never let anything display in front of this activity. I don't know what it does exactly though. I have seen the exact same behavior as you described in your question while developing for Google Glass. What I did was using View.setKeepScreenOn: http://developer.android.com/reference/android/view/View.html#setKeepScreenOn(boolean) – TomTasche Jan 30 '14 at 12:31
  • lol so i am not the only one who is confused with this new attribute. Anyways thanku for your help :) – Sheraz Ahmad Khilji Jan 31 '14 at 10:26
  • I am developing for XE16.11 and android:immersive="true" doesn't work. When screen is off and i tap glass, I only see Clock card... any suggestion? I use `android:immersive="true"` in the activities of the manifest. – Bae Apr 30 '14 at 14:02