What is android:immersive attribute in Android manifest file?

跟風遠走 提交于 2019-12-07 18:19:42

问题


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()

回答1:


"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.



来源:https://stackoverflow.com/questions/21450077/what-is-androidimmersive-attribute-in-android-manifest-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!