Reputation: 761
I want to know if it's possible to have 2 different actions when starting an app.
Like when you go to all programs and select your app you open the app
and if you open the app from the quick selection(I'm not sure if it's called this but a screen like this :
then it runs some code and shows me a Toast.
Is this possible?
Upvotes: 0
Views: 52
Reputation: 14472
Yes.
You register "intent filters" with Android in your manifest.xml. The "main" intent filter is the one that the launcher uses, and the only one the launcher uses, to start your app. So, if you start your app via the launcher, it will always start via the Activity associated with the "main" intent.
You can also register other intent filters e.g. send email. When a user is using a 3rd party app and selects "Send email", if Android has exactly one intent registered from an app that says "I can do that", it is launched via that intent. If more than one app has registered intents for "send email", Android displays the chooser you have shown in your question. If more than one app has registered intents for "send email", and the user has set an app to be the default app for the intent (hence the "use by default" checkbox), Android launches that app via the intent.
Start by reading about intent filters here:
http://developer.android.com/guide/topics/manifest/manifest-intro.html
Upvotes: 2