Open Android app with connection

1

I want to know how the Cerberus app, for Android, can open your app when we call a certain number?

For those who do not know Cerberus, it is an anti-theft application, so it hides its icon so that people do not realize that it is installed.

If you call the default number or what you registered, the application opens!

As we can see here:

  

'... or you can open the Cerberus on your phone by dialing the "dialing code" as if it were a phone number. If you have not changed, the default dialing code is 23723787. '

Does the app overwrite some OS precedence?

How can I do this?

    
asked by anonymous 29.04.2015 / 14:53

1 answer

3

You should create a BroadcastReceiver that intercepts the action Intent.ACTION_NEW_OUTGOING_CALL

public class OutgoingCallReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        final String numero = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

        String msg = "Acabou de marcar o seguinte numero: " + numero;
        Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
    }
}

You'll need to register BroadcastReceiver on AndroidManifest:

......
<receiver android:name="OutgoingCallReceiver">
    <intent-filter android:priority="1">
        <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
    </intent-filter>
 </receiver>
 ......

Do not forget to include the following permission:

<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
    
29.04.2015 / 15:03