I’m currently plugging away at my first Android app, and I’ve run into a hitch. I have a main activity that will launch a service, and every time the screen turns on, it’s supposed to make a toast. The only problem is that I’ve never used a Service before, and I don’t know how to make it interact with my Activity, ie: the toast will be a user-defined string.
I’m not asking for anyone to write it for me, I just need some help being pointed in the right direction.
In case the above wasn’t clear, basically, I want a service that will start when the main activity says start, then make a toast every time something happens (like the screen turning on or the phone being unlocked), and also stop only when the user presses stop.
Thanks for your help!
Look at
BroadcastReceiverit will pick up system notifications if you register it in theandroidmanifest.xmlwithIntentFilters. You can then use it to start aServiceor anActivitywith aPendingIntent