What is the meaning of android.intent.action.MAIN?

后端 未结 3 500
后悔当初
后悔当初 2020-12-02 05:25

I have seen so many different confusing explenations..


      
     

        
3条回答
  •  生来不讨喜
    2020-12-02 05:40

    ACTION_MAIN is considered an entry point for the application. Usually, it combines with CATEGORY_LAUNCHER in an to indicate an activity that should appear in the home screen's launcher, or in anything else that considers itself to be a launcher. Such "launchers" can query PackageManager, using queryIntentActivities(), to find such activities and display them to the user.

    However, ACTION_MAIN can be used in combination with other categories for other specialized purposes. For example, CATEGORY_CAR_DOCK with ACTION_MAIN indicates an activity that should be considered a candidate to be shown when the user drops their phone into a manufacturer-supplied car dock.

    When an Intent is used with startActivity(), if the Intent is not already placed into a category, it is placed into CATEGORY_DEFAULT. Hence, an needs to specify some , using if nothing else.

提交回复
热议问题