How can I reference the Activity
View
from within the onCreate()
method so I can use view.setKeepScreenOn()
.
Asked
Active
Viewed 4,850 times
1

David Snabel-Caunt
- 57,804
- 13
- 114
- 132

bugzy
- 7,086
- 9
- 42
- 44
-
See this link : "http://stackoverflow.com/questions/5712849/how-do-i-keep-the-screen-on-in-my-app" – Basher51 Nov 17 '14 at 07:51
2 Answers
3
You can get a specific view defined in your xml file like:
View view = findViewById(R.id.my_view);

Cheryl Simon
- 46,552
- 15
- 93
- 82
1
You could also use android:keepScreenOn
in your layout xml to have it set automatically when your layout is inflated. See the docs.

Vadim Kotov
- 8,084
- 8
- 48
- 62

Al.
- 76
- 1