vurmex.blogg.se

Windowmanager addview
Windowmanager addview











Note: To follow this tutorial, we consider that you know to create a new Android app with Android Studio.

  • Remove the image, and destruction of the service.
  • Detection of the unlocking of the smartphone by the user.
  • When the user presses button to turn on the smartphone, the image of the broken screen is visible.
  • For this we will use the service in a “ BroadcastReceiver” will allow us to detect the smartphone standby and unlocking (to delete the image and destroy the service).

    windowmanager addview

    To not our friend would suspect the joke, the service will add the image when the smartphone switches to standby. The display of the image of the broken screen must be through a program that has no GUI and is therefore not visible to the user. In our example, we use a service so that the user does not see our application running. In some cases, it is useful to create a program that runs in the background, without the application is visible, such as a music player (which works without the application open) or a timing system that performs actions at regular intervals. Why use a service in this tutorial Android ? The user therefore can not interact with it.

    windowmanager addview

    The big difference is an activity that has no GUI. As an activity, a service has a life cycle ( OnCreate (), OnStart ( Intent i) or OnStartCommand ( i Intent, int flags, int startId) and OnDestroy ()). A service, what is it?Ī service is a component that runs in the background. No stress, once your friend will unlock the smartphone, the false image disappear. He then discover its home screen with a false image of the broken screen.

    windowmanager addview

    Once the action taken, the application closes and nothing happens until the next use of the smartphone by your friend. The principle is simple, this application replaces the home screen of the smartphone with an image showing the broken screen.Īt launch, the application asks you to validate the joke by pressing the center button. To illustrate this concept little known and somewhat mysterious, we will create a small application to make a joke to your friends. We will learn through this Android tutorial how to use a “service” that runs in the background.













    Windowmanager addview