Previous words:
The original intention of this article is actually this. Recently, I want to guide users into the setup interface of the system when they start APP. So I saw this code on the internet:
Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if(Build.VERSION.SDK_INT >= 9){ intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS"); intent.setData(Uri.fromParts("package", mContext.getPackageName(), null)); } else if(Build.VERSION.SDK_INT <= 8){ intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.android.settings","com.android.settings.InstalledAppDetails"); intent.putExtra("com.android.settings.ApplicationPkgName", mContext.getPackageName()); } startActivity(intent);
I'm curious why I wrote "intent. setClassName" ("com. android. settings", "com. android. settings. InstalledAppDetails"); in this code. At the same time, they are subjected to This article Enlightenment is to play with the "adb shell dumpsys" command. After all, one of the major taboos of the code is that "the function is implemented, but the writing is not clear".
Okay, here comes the text.
Note: All the following commands need to be executed when the data line connects to the mobile phone. The best way to check whether the connection is successful is to see if the "Connected Devices" of Android Studio is displayed properly.
Capture the current activity "i.e., the active information of onResume is displayed on the interface of mobile phones currently connected to computers via USB":
Enter the following in the command line window:
adb shell dumpsys activity top
Output:
TASK null id=488 ACTIVITY com.android.settings/.applications.InstalledAppDetails 955e010 pid=13576 Local Activity d7e4b34 State: mResumed=false mStopped=true mFinished=false mChangingConfigurations=false mCurrentConfig={1.0 460mcc2mnc en_US ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h s.13 themeId=0, affectGlobal:true} mLoadersStarted=true Active Fragments in 517189: #0: InstalledAppDetails{c3b458e #0 id=0x7f120256} 「Omit a bunch of code」 ViewRoot: mAdded=true mRemoved=false mConsumeBatchedInputScheduled=false 「Omit some code」 View Hierarchy: com.android.internal.policy.PhoneWindow$DecorView{fee7866 V.E...... R....... 0,0-1080,1920} 「Most of the code is omitted. The main description of this part of the code is current. Activity Of View Hierarchical relationship」 Looper (main, tid 1) {6faf70a} (Total messages: 0, polling=false, quitting=false)
Actually, I already know what I want to know most.
「 ACTIVITY com.android.settings/.applications.InstalledAppDetails」
It's supposed to be over here, but aren't you surprised? Can I write this for Mao "android.settings.APPLICATION_DETAILS_SETTINGS"?
Haha, actually check Official You can see the following statement:
Look at the source code of android again and see the following explanation:
public static final String ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS = "android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS";
Ha-ha, there seems to be nothing to be strange about
Write here, actually should be over, but suddenly interested in the "adb shell dumpsys" command, in fact, this article is only the "adb shell dumpsys" command has a role in introducing, the next article continues to ~~
Reference article:
Detecting Active Task Stack of Android with adb shell dumpsys