Skip to content

How to set Default Actions for Activities

January 3, 2010

Hey everyone,

This example is about how to assign DEFAULT actions to various actions. For instance, if you want your home screen to be the default home screen, then in your manifest simply add:

<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<category android:name="android.intent.category.HOME"/> 
<category android:name="android.intent.category.DEFAULT" /> 
</intent-filter> 

To the activity that you want to be the default home screen. Another example involving the CALL_BUTTON (for instance, in my case I wanted to replace the dialer):

<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<action android:name="android.intent.action.CALL_BUTTON"/>
<category android:name="android.intent.category.DEFAULT" /> 
</intent-filter> 

And if you want to replace the default dial action, then it will be:

<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<action android:name="android.intent.action.DIAL" /> 
<category android:name="android.intent.category.DEFAULT" /> 
</intent-filter> 

So now if you start typing in a number from your home screen, your application will appear on the list of possible default behaviors.

Hope this was helpful. Happy coding.

– jwei

Advertisements
2 Comments leave one →
  1. Adam Richmond permalink
    January 4, 2010 8:00 pm

    This was very delicious.

    -Adam

  2. March 2, 2011 8:28 pm

    nice article. thx

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: