Launch Stock Apps using Intent
Some time we have to launch stock applications in our android phone without need of performing some action. Like Email, Browser,Calculator,Calendar, Contacts, Gallery, Market and so on. This can be done by using power full function makeMainSelectorActivity() method of Intent class.
Syntax is pretty simple, just to write few lines of code
Say you want to open email app.
Syntax is pretty simple, just to write few lines of code
Say you want to open email app.
Intent intent= Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_EMAIL);
startActivity(intent);
For other apps you just have to replace second parameter i.e. category.
Here is some app listed category from android developer refernce
CATEGORY_APP_BROWSERUsed withACTION_MAINto launch the browser application.-
Used with
ACTION_MAINto launch the calculator application. -
Used with
ACTION_MAINto launch the calendar application. -
Used with
ACTION_MAINto launch the contacts application. -
Used with
ACTION_MAINto launch the email application. -
Used with
ACTION_MAINto launch the gallery application. -
Used with
ACTION_MAINto launch the maps application. -
This activity allows the user to browse and download new applications.
-
Used with
ACTION_MAINto launch the messaging application. -
Used with
ACTION_MAINto launch the music application.
You can explore more to android docs for understanding power of Intents.
https://developer.android.com/reference/android/content/Intent.html#CATEGORY_ALTERNATIVE
Comments
Post a Comment