Open Android app with link

Asked

Viewed 1,744 times

1

I want to know, Cerberus, for Android, can open your application 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 Cerberus on the phone by dialing the "dial code" as if it were a phone number. If you have not changed, the default dial code is 23723787.'

The app overrides any OS precedence?

How can I do it?

1 answer

3

You must 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 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" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.