12

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.

CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
pengguang001
  • 4,045
  • 6
  • 27
  • 31

5 Answers5

22

This can be found in the application's manifest.

The main activity is the activity with the intent-filter whose name is android.intent.action.MAIN.

Tony the Pony
  • 40,327
  • 71
  • 187
  • 281
8

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.

dmon
  • 30,048
  • 8
  • 87
  • 96
5

Step1: Start "adb logcat" in command prompt.

Step2: Open the app (either in emulator or real device) enter image description here

Rameshwar
  • 541
  • 6
  • 22
4

Just go to Android package n open Android Manifest File n check out this activity element

<activity>
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
</activity>
bytecode77
  • 14,163
  • 30
  • 110
  • 141
Ajit Gupta
  • 49
  • 1
4

You don't need to know it's name, instead you should use implicit intent and specify action along with type and some extras, for example

            final Intent intent = new Intent();
            intent.setType("message/rfc822");
            intent.setAction(Intent.ACTION_SEND);
            intent.putExtra(Intent.EXTRA_SUBJECT, "Some subject");

System will search for components available to run this intent.

ernazm
  • 9,208
  • 4
  • 44
  • 51