Programme description:
1. Through the Register broadcast receiver listens for the user to call the telephone operation;
2. When the user dials the telephone, the broadcast receiver receives the number and contrasts with the specified "password", if it matches, initiates an interface and terminates the user's call operation.
Realize:
1. Configure the broadcast receiver in the manifest file and add permissions:
<receiver
android:name= "Cn.edu.chd.mobilesafe.receiver.CallPhoneReceiver"
>
< Intent-filter
android:priority= "1000"
>
<action android:name= "Android.intent.action.NEW_" Outgoing_call "/>
</intent-filter>
</receiver>
Permissions:
<uses-permission android:name= "Android.permission.PROCESS_OUTGOING_CALLS"/>
2. Processing in the broadcast receiver OnReceive method:
public class Callphonereceiver extends Broadcastreceiver
{
private static final String CODE = "a";
@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);
Terminate phone dial
setresultdata (null);}
}
This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/