Android - how to find the name of the main activity of the 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 

Available via decompilation apk, but it's complicated.

+8
source share
5 answers

You can connect your phone to a computer and look at the DDMS log, applications are printed there, for example:

 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 apparently be the right choice, at least for what launches the icon.

+7
source

This can be found in the application manifest.

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

+15
source

Step1: Run "adb logcat" on the command line.

Step 2. Open the application (either in the emulator or in a real device) enter image description here

+5
source

You do not need to know this name, instead you should use an implicit intent and specify the action along with the type and some additional functions, for example

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

The system will look for components available to run this intent.

+4
source

Just go into the Android package n Open the Android manifest file n check this activity item

 <activity> <intent-filter> <action android:name="android.intent.action.MAIN" /> </activity> 
+3
source

Source: https://habr.com/ru/post/887832/


All Articles