Blink upon incoming call android
I am developing an android app, where I want make the home screen blink
upon incoming call. I tried calling the below startblinking() method
within a activity and the screen blinks fine.
But, when I try to call the same method within the Ring state of a
phonelistener(inside a Service class), I get the following error, since
the service class doesnt have a window.
The method getWindow() is undefined for the type PhoneListener
..
private void startblinking()
{
Log.e("inside","blink MEthod");
timerforblinking.scheduleAtFixedRate(new TimerTask()
{
@Override
public void run()
{
runOnUiThread(new Runnable()
{
public void run()
{
time = (float) (time + 0.5);
if(time == 0.5 || time == 1.5 || time == 2.5 || time
== 3.5 || time == 4.5 || time == 5.5)
{
Log.e("time","OFF - time = "+time);
layoutParams.screenBrightness = (float) 30 / 255;
getWindow().setAttributes(layoutParams);
}
if(time == 1.0 || time == 2.0 ||time == 3.0 ||time ==
4.0 ||time == 5.0 )
{
Log.e("time","ON - time = "+time);
layoutParams.screenBrightness = (float)255 / 255;
getWindow().setAttributes(layoutParams);
}
if(time >= 6.0)
{
layoutParams.screenBrightness = (float)255 / 255;
getWindow().setAttributes(layoutParams);
timerforblinking.purge();
timerforblinking.cancel();
}
}
});
}
}, 0, 500);
Is there a possible workaround to achieve the screen blinking upon
incoming calls.
Please help.Thanks!
No comments:
Post a Comment