Modify the Manifest.xml File
<receiver android:name="receivers.SecretCodeReceiver">
<intent-filter >
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" />
</intent-filter>
</receiver>
And change the broadcast receiver class
if(intent.getAction().equals("android.provider.Telephony.SECRET_CODE")) {
String uri = intent.getDataString();
String[] sep = uri.split("://");
if (sep[1].equalsIgnoreCase("1234")) {
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("com.whatsapp");
context.startActivity(launchIntent);
} else if (sep[1].equalsIgnoreCase("5678")) {
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("net.one97.paytm");
context.startActivity(launchIntent);
}
}
Now dial the number from the dialer *#*#NUMBER#*#*for example. *#*#1234#*#*to run whatsapp
source
share