It is actually very simple. This is a self-contained function on the mobile phone. You do not need to press any combination of buttons at the same time. Instead, you can dial on the dialing interface. Click "Dialer" on the main screen of the system to enter the dialing interface. Enter "* #* #4636 # *" (without quotation marks) to enter the project testing mode. The Testing interface is displayed, which includes four options: Phone information, Battery information, Battery history, and Usage statistics. For example, to view the historical running time of a program, click the last Usage statistics command to list the historical running time of each program. LogCat prints the following information: For example, we can see the Activity package name: com. android. settings Class Name: UsageStates In this way, we can write a small program to call the program. The Code is as follows: Main. xml <? Xml version = "1.0" encoding = "UTF-8"?> <Br/> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" <br/> android: orientation = "vertical" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "fill_parent" <br/> <Button <br/> android: id = "@ + id/button" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "wrap_content" <br/> android: text = "Application Usage Statistics" <br/> </p> </LinearLayout> <br/> ActivityMain. java Public class ActivityMain extends Activity {<br/> private Button button; <br/> @ Override <br/> public void onCreate (Bundle savedInstanceState) {<br/> super. onCreate (savedInstanceState); <br/> setContentView (R. layout. main); </p> <p> button = (Button) findViewById (R. id. button); </p> <p> button. setOnClickListener (new Button. onClickListener () {<br/> @ Override <br/> public void onClick (View v) {<br/> Intent intent = new Intent (Intent. ACTION_MAIN); <br/> intent. setComponent (new ComponentName ("com. android. settings "," com. android. settings. usageStats "); <br/> // intent. setClassName ("com. android. settings "," UsageStats "); <br/> startActivity (intent); <br/>}</p> <p> }); </p> <p >}< br/>} Program running result: |