Thursday, 22 August 2013

multiple intent in broadcast receiver

multiple intent in broadcast receiver

So I am making an app that listens for Screen On activity in android. I
have a broadcast receiver that receives Intent.ACTION_SCREEN_ON. This
receiver then starts an activity.
Everything works fine but it starts the activity even when the screen was
on because of an incoming call.
This is my code.
if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)){
Intent i = new Intent(context, MainScreenActivity.class);
i.putExtras(intent);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Log.e("receiver", "throwing in the lock screen");
}
I am not quite sure how to I check the current state of the phone. I have
the permission to read PHONE_STATE but how do I find out if the sceen on
action was fired because of the call?
Also there is a delay when the screen is actually turned on and the
activity is displayed. The default lock screen is visible for a short time
and then the custom one appears. Is there anything that can be done to
avoid this delay?

No comments:

Post a Comment