Prash's Blog

Basic Patterns for Mobile Navigation September 12, 2016

Filed under: Android — prazjain @ 1:14 pm
Tags: , ,




How to show message count on app icon in Android June 6, 2014

Filed under: Android — prazjain @ 9:08 pm

I was curious about how whatsapp and facebook showed a count of unread messages or notifications on app icon in Android, and I wanted to find that out for myself.

It is explained well in the link below.

//This is for samsung touchwiz

public static void setBadge(Context context, int count) {
    String launcherClassName = getLauncherClassName(context);
    if (launcherClassName == null) {
    Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
    intent.putExtra("badge_count", count);
    intent.putExtra("badge_count_package_name", context.getPackageName());
    intent.putExtra("badge_count_class_name", launcherClassName);

public static String getLauncherClassName(Context context) {

    PackageManager pm = context.getPackageManager();

    Intent intent = new Intent(Intent.ACTION_MAIN);

    List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 0);
    for (ResolveInfo resolveInfo : resolveInfos) {
        String pkgName = resolveInfo.activityInfo.applicationInfo.packageName;
        if (pkgName.equalsIgnoreCase(context.getPackageName())) {
            String className =;
            return className;
    return null;

Sony devices use a class named BadgeReciever.
Declare the com.sonyericsson.home.permission.BROADCAST_BADGE permission in your manifest file:
Broadcast an Intent to the BadgeReceiver:

Intent intent = new Intent();

intent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", "com.yourdomain.yourapp.MainActivity");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", true);
intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", "99");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", "com.yourdomain.yourapp");


Done. Once this Intent is broadcast the launcher should show a badge on your application icon.

To remove the badge again, simply send a new broadcast, this time with SHOW_MESSAGE set to false:

intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", false);

More details in the links below how-to-display-count-of-notifications-in-app-launcher-icon



Android browser home page hijacked by September 8, 2012

Filed under: Android — prazjain @ 10:30 am
Tags: , , ,

I got my Android browser home page hijacked by I traced it to installing a random app “Remote Gallery 3d” I found on a blog. This app also created a shortcut “Search” in my android shortcut panel.
This is how I got rid of it, hope it will help you too.
1) Remove “Search” from the shortcut panel in android.
2) Go to Settings -> Applications -> All -> Internet.
3) Clear cache data and clear data.
4) Restart Android browser to check.


Android app Flight Flash on Google Play now! May 22, 2012

Filed under: Android — prazjain @ 1:26 am

Just released my second android app Flight Flash on Google Play.

Flight Flash gives you latest and up to date information on flight arrivals and departures from your city airport.
It supports both domestic and international flights.
Currently available for India and UK.
Supported cities in India : Bangalore, Chennai, Mumbai, New Delhi.
Supported airports in UK : London Heathrow, London Stansted, London Gatwick, London City Airport, London Luton.

Let me know if you like to see your favourite city or airport added to the list.


How to setup android emulator display for a phone April 25, 2012

Filed under: Android — prazjain @ 11:41 am
Tags: , ,

I was facing a similar problem some time back, when I was writing an android app, and wanted to test it in the emulator with the display settings of the phone.

This is how I set up android emulator for samsung galaxy s2.

  • In Eclipse, go to Windows to start AVD Manager.
  • Select the AVD that you have created already, and click on edit.

  • Set resolution to 480 * 800. Click Edit AVD.

  • Click on Start. Select Scale display to real size. Set screen size to 4.3. For monitor dip, click on the “?”, enter your monitor’s Screen size and select its current resolution. Click ok. Click Launch.


How to set Android App orientation on startup April 21, 2012

Filed under: Android — prazjain @ 5:50 pm

While coding one of the android app, i overwrote OnConfigurationChanged method to change the app orientation when user changes orientation. But there was a problem if the user starts the app in landscape mode, my app would by default still load in portrait mode. So add this little bit of code to check the orientation when you start your app and set the it accordingly.

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) 
        Configuration conf = this.getResources().getConfiguration();
    	if (conf.orientation== Configuration.ORIENTATION_LANDSCAPE)
    	else if (conf.orientation== Configuration.ORIENTATION_PORTRAIT)

Metro Journey Planner Android App February 7, 2012

Filed under: Android — prazjain @ 3:54 pm
Tags: , , ,

There are loads of journey planner apps out there, but none that were good for the indian metro trains.
So I decided to write one, here is the link :
Some things that I have added in this app, which are missing from other similar apps for Indian market are : ability to find shortest route from source to destination, intuitive user interface.
The user interface is much easy to use.
Try it out.
Of course feedback is welcome.
I will keep updating the application in terms of User Interface, and Functionality on time to time basis,
but if there is something urgent you will like to address soon then do drop me a line.

Currently supports Bangalore and New Delhi metros.