Debug Android手机应用一般用来检查比较难的问题,一般问题通过查看日志信息就可以解决。
1. 在Application Resources->Descriptors->META-INF中,找到logging.prcoperties文件,设置日志级别
比如把如下Package的级别从默认的SEVERE改为INFO:
(1)oracle.adfmf.util.logging.ConsoleHandler.level=INFO
(2)oracle.adfmf.framework.level=INFO
(3)oracle.adfmf.application.level=INFO
2. 修改Managed Bean,增加Logger语句
package mycomp.mobile;
import com.sun.util.logging.Level;
import com.sun.util.logging.Logger;
import oracle.adf.model.datacontrols.device.DeviceManager;
import oracle.adf.model.datacontrols.device.DeviceManagerFactory;
import oracle.adfmf.amx.event.ActionEvent;
import oracle.adfmf.util.Utility;
public class BackingPic {
public BackingPic() {
}
public void sendEmail(ActionEvent actionEvent) {
System.out.println("This is logging test from System.out.println()");
Logger.getLogger(Utility.APP_LOGNAME).logp(Level.INFO, this.getClass().getName(), "Logger","This is logging test from Logger");
// Add event code here...
DeviceManager deviceManager = DeviceManagerFactory.getDeviceManager();
//deviceManager.sendEmail("ping.ma@oracle.com", "", "An Email", "Hello from me.", "", "", "");
deviceManager.sendEmail("maping930883@hotmail.com", "", "An Email", "Hello from me.", "", "", "");
}
}
注意,使用System.out.println()方式打印信息适用临时查看信息,建议还是使用Logger打印调试信息。
3. 在命令窗口下,进入C:\Program Files (x86)\Android\android-sdk\tools,运行ddms.bat
可以看到,打印出了 System.out.println和Logger语句信息:
05-15 03:09:52.116: D/CVM(1205): ######## This is logging test from System.out.println()
05-15 03:09:52.156: D/CVM(1205): [INFO - oracle.adfmf.application - BackingPic - Logger] ######## This is logging test from Logger
05-15 03:09:52.156: D/CVM(1205): [INFO - oracle.adfmf.application - BackingPic - Logger] ######## This is logging test from Logger
1. http://www.youtube.com/watch?v=5yyY7_U6GgY
2. https://blogs.oracle.com/shay/entry/adf_mobile_logging_on_android
没有评论:
发表评论