How to call an activity's onResume method from a Receiver
I have an activity named GameTray where drawings carried are out. I have a
ScreenReceiver which extends BroadcastReceiver, this is for detecting
screen lock and phone lock. I want to save the datas while a screen lock
occurs in the GameTray activity. onResume method of GameTray contains all
the saving things. So I have a doubt, How can I call the onResume method
method of GameTray activity in the ScreenReceiver class while overriding
onReceive method? Am attaching the source for ScreenReciever here. Thanks
in advance
public class ScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
{
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF))
{
// Log.v("$$$$$$", "In Method: ACTION_SCREEN_OFF");
// onPause() will be called.
}
else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON))
{
// Log.v("$$$$$$", "In Method: ACTION_SCREEN_ON");
// HERE I WANT TO CALL THE ONRESUME METHOD OF THE ACTIVITY
GAMETRAY.
}
else if(intent.getAction().equals(Intent.ACTION_USER_PRESENT))
{
// HERE I WANT TO CALL THE ONRESUME METHOD OF THE ACTIVITY
GAMETRAY.
}
}
}
No comments:
Post a Comment