How to start a secret interface by dialing a specified number in the Dial-up interface

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.