The Android debugging procedure is correct.

Source: Internet
Author: User

Android is an open-source mobile operating system. You can write the operating system with the help of the simulator to meet your specific needs. The Android System is no longer valid (at least I use it). How can I implement the Android debugging program?

  • Android Core Module Content Overview
  • Android Browser
  • Android digital certificate specific application mechanism
  • Android Data Storage Access Mechanism
  • Available Android APIs

The first is to use Debug to set a breakpoint for tracking, but I feel uncomfortable. I am used to using System. out, and can also use Log without System. out.

The second type is the Log I want to introduce. After reading the methods introduced by others, I tried it myself and wrote it again ~. First of all, let's briefly introduce Android. Android is actually another version of the Linux mobile platform (I am not very familiar with Android, so I think so ), since it is Linux, the command will be used. So how to run the program with commands? Run the adb command! Type "cmd" and then type "adb shell". A "#" sign is displayed. Congratulations, you can use the command to control Android.

Run "am-help" to view the help information of the "am" command, and try to run "am start-n com. google. android. browser/com. google. android. browser. browserActivity "look? Haha, you can see in the simulator that the browser is running. Haha, the Android debugging program is so simple (Simple P, it took me a long time to find this stuff ).

Also:

 
 
  1. // Run the browser to open chinacnet
  2. # Am start-a android. intent. action. VIEW-d http://www.china.com
  3. Am start-a android. intent. action. VIEW-d http://www.china.com
  4. Starting: Intent {action = android. intent. action.
    VIEW data = http://www.china.com}

 
 
  1. // Call 123456789
  2. # Am start-a android. intent. action. CALL-d tel: 123456789
  3. Am start-a android. intent. action. CALL-d tel: 123456789
  4. Starting: Intent {action = android. intent. action. CALL
    Data = tel: 123456789}
 
 
  1. # am start -a android.intent.action.ALL_APPS   
  2. am start -a android.intent.action.ALL_APPS   
  3. Starting: Intent { action=android.intent.action.ALL_APPS }  

 
 
  1. // Google Map, to the shanghai dot package (Note: The dot package is a dialect, meaning a place)
  2. # Am start-a android. intent. action. VIEW geo: 0, 0? Q = shanghai
  3. Am start-a android. intent. action. VIEW geo: 0, 0? Q = shanghai
  4. Starting: Intent {action = android. intent. action.
    VIEW data = geo: 0, 0? Q = shanghai}

Now, I will briefly introduce how to view the output statements by using commands in the Android debugging program? You can use the Log class in Android, and the Log class is in the android. util package. The Log class provides several static methods:

 
 
  1. Log.v(String tag, String msg);   
  2. Log.d(String tag, String msg);   
  3. Log.i(String tag, String msg);   
  4. Log.w(String tag, String msg);   
  5. Log.e(String tag, String msg);  

Corresponds to Verbose, Debug, Info, Warning, and Error respectively.

A tag is an identifier and can be any string. Generally, you can use the class name + method name to provide a filter condition when viewing logs.

After the program runs, it does not output any information in the ide console. How can I view the log output? Run the "adb logcat" command:

 
 
  1. adb logcat  

After adb logcat is executed, all log information is displayed in tail mode in real time.

At this time, we usually need to filter the information to display the information we need. At this time, the tag we specify will be used.

 
 
  1. adb logcat -s MyAndroid:I 

Explanation: Only logs Whose tag is MyAndroid and whose level is I or higher than I (Warning, Error) are displayed.

There is also a better method. If your IDE uses Eclipse, you can select Locat in show view to view the output directly.

Now, you can implement the Android debugging program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.