Lets imagina that i have a Facebook button.

It works this way:

1) Detects if there is Facebook application installed.

2) If is - runs the facebook app.

3) If not - opens browser on facebook.com ( this i can do )

 

How to make 2 first activities? Is it possible?