O'Reilly logo

Learning Android Intents by Wajahat Karim, Muhammad Usama bin Aftab

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting the screen on/off state of a phone

Almost in all Android phones, we have seen a very interesting feature while attending a phone call; we can see that the screen goes on or off. In addition to this, you might have observed that when you bring your phone near your ear, the screen turns off, and when you take it away from your ear and hold it in your hand, the screen automatically turns on. This is an interesting behavior of smartphones. Let's say that we want to develop an application in which whenever the screen turns on, we want to turn on the speaker mode so that other people with us can hear and participate in the phone conversation. And when we put it on our ear again and the screen turns off, we want to turn speaker mode off. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required