I’m writing a software suite for Android devices that will keep track of call times and various other call info. I’d like one of the applications to run as a Service without being started from an Activity, and I’d like it to initialize immediately when the phone boots, and stay running constantly, listening for phone calls, logging information to a database as necessary. The Service will need to present a dialog to the user at the end of each call.
2 questions:
-
How do I get the program (Service) to initialize at boot automatically with no user setting or interaction required?
-
I was under the impression that you cannot instantiate and display dialogs without using an Activity. I would like the dialogs to appear laid over whatever the user currently has on the screen, and display a dialog. Is there a way to make an Activity completely transparent over the current Activity or is there a way to display dialogs from a Service?
thanks in advance.
Add this permission to your manifest:
Then add a receiver to your manifest:
Create a receiver in Java code:
Yes, that’s true. You have to have an activity that pops up the dialog. To create a transparent activity add the following style in your
res/values/styles.xmlfile (if you don’t have one, create it.) Here’s a complete file:Then apply the style to your activity, for example: