views:

516

answers:

3

Hello community,

If I want to create custom address book (which overrides my phone's default address book), and if I want it to be used by all applications, what should be my intent filter? Does Android allow me to do such a thing considering the fact that such a third-party app could potentially be malicious?!

And, if I want to have yet another address book application, I suppose the second app also has same intent-filter, isn't it? How does the framework decide which app to pick if I click on Contacts button when making a call? In other words, how does the framework resolve intents in case there is a conflict between multiple intent-filters?

I'm new to android, so please excuse me if this question is stupid. I would like to get some feedback in any case!

Thanks in advance,

Saksham

+1  A: 

You can replace any application on Android platform, even Home. Android documentation explains everything there is to know about Intents and Intent Filters and there is a section called Intent Resolution that answers your question. Intent Resolution section for Intent class has some additional information.

As far as I can tell Android doesn't try to resolve a conflict. It ask the user which application to run and gives them the choice to mark this Activity as the default for this Intent. They give an example about mail app here.

Nikola Smiljanić
Hi Nikola,Thanks for your reply. I have read the documentation on android developers' portal. However, the answer to my question still eludes me...From what I understood, if an activity/application advertises that it supports certain intent using appropriate intent-filters, then the framework can route intent to that activity easily. However, my question is: if there are two applications with exactly same intent filter, how does the framework pick one? Don't say by rolling a dice . :)Saksham
Saksham
A: 

While Mr. Smiljanić is basically correct, there is no Contacts application in Android for you to replace. There is Dialtacts, which is the application supporting the contacts, call log, and dialer. That application cannot be replaced, mostly because the dialer cannot be replaced.

So, while you may be able to override some intent filters and get control on some contacts-related requests, you will be unable to get the contacts portion of Dialtacts overridden, which will confuse users.

CommonsWare
HTC have made their custom address book with the Sense UI, and one of the things I've read online (which I might have misunderstood) is that you can customize pretty much everything on Android using appropriate intents/intent-filters. Question is, can I override the address book in, for instance, HTC hero? If I can, then what if I have address book apps A and B; which one will the framework pick?Many thanks
Saksham
"that you can customize pretty much everything on Android using appropriate intents/intent-filters" -- on the whole, yes. However, "pretty much everything" != "everything". You cannot replace Dialtacts on a Hero.
CommonsWare
A: 

I had given same intent filters for two different activities... ( )

It launches the activity which comes first in manifest file....

Brigadier
What if there are two applications, rathe than just one?
Casebash