tags:

views:

70

answers:

1

Hello all Androiders.

I am trying to build an app on my wife's phone that pranks her on April 01, April Fool's day of course. The app is going to change her background to look like the screen was cracked, the background is very convincing when I try it on my Droid (I was pranked similarly).

Anyway, digging into how this would work, I think its quite the process, however, I may be looking too far into this. I started diving into setting an alarm, however, I am confused about a couple things:

  1. Would it be necessary for my wife's phone to load this prank application in the background each time she reboots her phone? I am assuming yes, as I believe this prank application would most likely invoke a broadcast receiver to "listen" for April 01, 2011?

  2. If the application doesn't need to load each time in the background, what facilitates Android alerting my application and firing it when April 01, 2011 comes around?

I hope that makes any sense, basically, I want to ensure this application runs on April 01, 2011 even if my wife's phone crashes or reboots.

What would be the most straightforward method of making this work? I apologize if I don't understand broadcast receivers properly, this is quite the new concept which I am not use to. The Service and Broadcast Receiver functionality is native to Android and not any other language, no?

Thanks for helping this NEWB :)

+1  A: 

Bit too early for planning for April Fools,eh? :)

All you need is a single BroadcastReciever.

Create a BroadcastReciever add BOOT_COMPLETED to its intent filter. You're onRecieve() will be called. This will happen in 2 cases

1) Your Phone Booted up.

2) Your hit the Alarm.

To check which event occured, Check if your recieved Intent Action is "BOOT_COMPLETED", if it is then your phone booted up so setup an alarm for April 1, 2011. (Technically, you should have your own Custom Intent Action, but you don't need it in this case...)

Now, if your Action wasn't the Boot completed it means its april 1 so in that case change the wallpaper, using the WallpaperManager. Your new wallpaper will obviously be in your resources..

void onRecieve(Context ctx,Intent intent)
{
if( intent.getAction.equals( /* Boot Completed */)
{
   //setup alarm using alarm manager
}else
{
   //change wallpaper.
}
}

I'm sorry if i misunderstood you question, did you need help with the Alarm Manager?

Ofcourse, As Macarse pointed out you'll need SET_WALLPAPER and RECEIVE_BOOT_COMPLETED Permissions.

st0le
You will also need all the permissions to do so.
Macarse
@Macarse, updated! :)
st0le
That is exactly what I was looking for, excellent, the Boot Completed "flag" is precisely the part I was missing.
AutoM8R