Program Description:1. By registering the broadcast receiver to listen to the user to call the operation; 2. When the user dials the phone, the broadcast recipient receives the number and, in contrast to the specified "password", launches an interface and terminates the user's call operation if it matches.
implementation:
1. Configure the broadcast recipient in the manifest file and add the permissions:
<receiver android:name= "Cn.edu.chd.mobilesafe.receiver.CallPhoneReceiver" > < Intent-filter android:priority= " > <action android:name=" android.intent.action.NEW_ Outgoing_call "/> </intent-filter> </receiver>
Permissions:
2. Processing in the broadcast recipient OnReceive method:
public class Callphonereceiver extends broadcastreceiver{ private static final String CODE = ""; @Override public void OnReceive (context context, Intent Intent) { String number = Getresultdata (); if (code.equals (number)) { Intent myintent = new Intent (context,demoactivity.class); Myintent.addflags (intent.flag_activity_new_task); Context.startactivity (myintent); Terminating outgoing calls setresultdata (null);} }