Now most of the applications will boot from the boot, call the butler is more so, added the boot monitoring service after the boot, even if you do not open the call Butler application, the same can intercept incoming call information.
How to start the activity or service from boot:
Main steps:
1. To have the service or activity to start the boot (this is the boot to start the listenservice of course)
2. Write a broadcastreceiver to capture the action_boot_completed broadcast and start the activity or service we want to activate after capturing.
Bootcompletedreceiver.java
Package Com.example.callmanager;import Android.app.activity;import Android.content.broadcastreceiver;import Android.content.context;import Android.content.intent;import Android.content.sharedpreferences;public Class Bootcompletedreceiver extends Broadcastreceiver {sharedpreferences spf; @Overridepublic void OnReceive (Context context , Intent Intent) {if (Intent.getaction (). Equals (intent.action_boot_completed)) {SPF = Context.getsharedpreferences (" Setting ", activity.mode_private); Intent newintent = new Intent ("Com.example.callmanager.ListenService"); Newintent.addflags (intent.flag_activity_new_task); Note that this tag must be added, otherwise the start will fail System.out.println ("Start by broadcast"); if (Spf.getboolean ("Isstartlisten", false)) Context.startservice (newintent);}}}
Here also take out the user's settings information, if the user does not enable monitoring services, the boot does not start monitoring services, more humane.
3. Register our Broadcastreceiver in the Androidmanifest.xml configuration file
<receiver android:name= ". Bootcompletedreceiver "><intent-filter> <action android:name=" android.intent.action.BOOT_ Completed "/></intent-filter> </receiver>
4. Add permissions in the Androidmanifest.xml configuration file that allow us to capture the broadcast
This enables the start-up of activity or service with the above four steps.
At this point, the call Butler's basic interception function, as well as display interception information, timing interception, monitoring switch, interception mode function has been fully realized, of course, the application can continue to improve, such as, the interception of records to add notification bar, the production of application Start screen, add gesture swipe, add more rich features such as SMS interception.
Attached: Full code download
Android Project Call Butler (8)-----Add boot monitoring Service