Search code examples
androidandroid-activity

android - how to find the name of the main activity of an application?


For example, I want to start Gmail in code/command line, but I don't know its main activity name.

am start -n com.google.android.gm/.XXXXX

It's available through decompiling the apk, but it's difficult.


Solution

  • You can plug your phone into the computer and look at the DDMS log, application launches are printed there, e.g:

    05-11 09:19:15.725: INFO/ActivityManager(96): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x2000000 cmp=com.google.android.gm/.ConversationListActivity bnds=[125,410][235,540] } from pid 2457
    

    So, com.google.android.gm/.ConversationListActivity, would seem like the right choice, at least, that's what the icon seems to launch.