Use Ddms and add debug message in your application.

DDMS是開發Android所必備的debug tool,它的功能有:

–Devices - Shows the list of devices and AVDs that are connected to ADB.
–Emulator Control - Lets you carry out device functions.
LogCat - Lets you view system log messages in real time.
Threads - Shows currently running threads within a VM.
–Heap - Shows heap usage for a VM.
–Allocation Tracker - Shows the memory allocation of objects.
File Explorer - Lets you explore the device's file system.

紅色是最重要的功能.


[ Using LogCat ]

LogCat is integrated into DDMS, and outputs the messages that you print out using the Log class. 
因為我們要debug程式,所以要了解其用法:
•logcat messages type:
– Verbose
– Debug
– Info
– Warn
– Error
The Log class:
v(String, String) (verbose) 
d(String, String) (debug) 
i(String, String) (information) 
w(String, String) (warning) 


For example: Log.i("MyActivity", "MyClass.getView() — get item number " + position);

output : I/MyActivity( 1557): MyClass.getView() — get item number 1;

知道語法後就可以開始debug了.

[ 改寫程式,加入debug message ]


 package com.firstapp;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class firstapp extends Activity {
    
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          TextView tv = new TextView(this);
          tv.setText("Hello, Mark's Android first APP");
          int position=1;
          Log.i("first app","this app- first app.java" + position);
          setContentView(tv);
         
      }            
}


[ Output debug message with logcat]

留言

這個網誌中的熱門文章

最爛的銀行服務-玉山銀行

Mark App Design Apps - Terms and Privacy Policy (服務條款,隱私權政策)

SMR疊瓦式hdd致命缺陷被解決????!!!

ios app 上架時app icon要注意事項

更改google drive預設存放目錄位置Change Google Drive Default Folder Location in Windows

google play 正式發布前測試報告...非常好用.

舊有app在Android 12 閃退問題& app Splash screens

app bundle and bundletool. 關於aab安裝問題

關於google play console app應用程式簽署

Google Play badge徽章產生器