While the phone is sleeping I want to have an animated activity (much like the phone ringer animation).
I've read many posts regarding turning the screen on using the WindowManager flags, so what I did was adding this piece of code to my activity's onCreate() function:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
);
setContentView(R.layout.act_image_activity);
startAnimation();
}
My issues are:
- The animation starts with a small delay; when the screen turns on, I can see the keyguard (or the home screen when the keyguard is disabled), and after that my activity kicks in.
- After calling my activity's finish() method, the phone doesn't go to sleep right away, rather it starts the sleep timer all over again.
Can someone please tell me how can I get my animated activity to display immediately after the screen turns on, and have the screen turn off immediately after it finishes ?