1.在清单文件中配置广播接收者,并添加权限:
<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>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
public class CallPhoneReceiver extends BroadcastReceiver { private static final String CODE = "110"; @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); //终止电话外拨 setResultData(null); } } }
【安卓笔记】在拨号界面通过拨打指定号码来启动某个秘密界面,布布扣,bubuko.com
原文:http://blog.csdn.net/chdjj/article/details/37705403