Home > Tricks & Tips > Launch your applications on custom secret code

Launch your applications on custom secret code


You might know about some of Android Secret Number or Code, right?

For sample, on the dial pad, type this code: *#*#4636#*#*, the a Testing screen will appear; it’s a secret screen that you do/don’t know about it before.

Dial Pad on SecretCode

Dial Pad on SecretCode

The interesting point here is that you absolutely want to do the same thing, type your custom secret code and your app is launched immediately.

This is what you need to do for it.

1. Create a custom BroadcastReceiver for Secret Code entering; for sample, I named it MySecretCodeReceiver.

This receiver will launch my Activity on detection.

public class MySecretCodeReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		if(intent.getAction().equals("android.provider.Telephony.SECRET_CODE")) {
			Intent i = new Intent(context, MainActivity.class);
			i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(i);
		}
	}

}

2. Register the MySecretCodeReceiver properly, like below:

        <receiver android:name=".MySecretCodeReceiver">
    	 	<intent-filter>
          		<action android:name="android.provider.Telephony.SECRET_CODE" />
         		<data android:scheme="android_secret_code" android:host="1711" />
   		</intent-filter>
        </receiver>

You need to make sure that the tag <action> should be like exactly same as above, since it’s the pre-defined action for SECRET_CODE handling. Also, pick a number in attribute “android:host” to your application. For sample here, I pick my lucky number 1711.

That’s pretty much straightforward. Have fun anyway!

Cheers,

Pete Houston

Advertisements
Categories: Tricks & Tips Tags: , , ,
  1. Paulo Teixeira
    August 27, 2013 at 12:56 am

    Hi. I tried to apply this code but it seems that custom codes are filtered out as nothing happens, but if I use an existing one, lets say 4636, then it works. Am I missing something, I even tried using your lucky number (hehe), assuming if it worked for you it woul work for me, but nothing.

    • NorthernPaladin
      October 15, 2014 at 3:43 am

      I’ve noticed this on the Galaxy S4 in particular. Did you ever find a solution? There must be a list of numbers somewhere and perhaps it can be edited.

      • Paulo Teixeira
        December 31, 2016 at 6:01 pm

        Hi,

        Indeed this was only working on a Galaxy S4. So I just sticked with the 4636 code to do the task that we needed to. I do not recall if we had this working with other codes on other phones – this was a long time ago.

    • Sai
      December 31, 2016 at 2:19 am

      Even i tried 4636 also the was not working. plz provide code .

      • Paulo Teixeira
        December 31, 2016 at 6:06 pm

        As far as I know the 4636 code is broadly used on Galaxy S4’s. As for the code if you apply whats on the post it should just work. At least when I tried it out it worked on Galaxy S4 with the 4636 code, but not with any custom code, and I could not find a solution, so I just applied the code 4636 and only for Galaxy S4 smartphones. It was enough for us at the time.

  2. redbulletnl
    August 15, 2012 at 4:34 pm

    why would you dial your app instead create shortcut?

    • January 31, 2013 at 2:59 am

      In situations like SuperUser, you can hide the app or lock it with the pro version and the only way into the application is to dial a code you setup.

    • Paulo Teixeira
      December 31, 2016 at 6:25 pm

      We actually had a use case where we needed to perform a background action on our app on demand, which was only meant to be executed on a schedule or on certain events. With the code we could trigger the action whenever we wanted.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: