Archive

Archive for August, 2012

Fonts for Programming

August 18, 2012 Leave a comment

There’re some good fonts for programming.

+ Consolas

+ Andale Monotype 8pt

+ Sheldon 8pt

+ ProFont 8pt

+ Courier New 8pt

+ Droid Sans Mono

+ DejaVu Sans Mono

+ Mocano (not fixed width)

+ Inconsolata (this font seems to be incompleted)

+ Lucida Console 8pt

+ Courier New

+ Dina

+ Bitstream Vera Sans Mono

+ Terminal

 

Categories: Of Diary Tags: ,

Launch your applications on custom secret code

August 13, 2012 8 comments

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

Categories: Tricks & Tips Tags: , , ,