LifecycleEvents演示了如何使用Lifecycle Event Handlers。
知识点:
1. 应用级的Lifecycle Event Listener
AppHandler.java 代码:
package application;
import com.sun.util.logging.Level;
import oracle.adfmf.application.LifeCycleListener;
import oracle.adfmf.util.Utility;
import oracle.adfmf.util.logging.Trace;
public class AppHandler implements LifeCycleListener {
public AppHandler() {
super();
}
public void start() {
Trace.log(Utility.ApplicationLogger, Level.SEVERE, AppHandler.class, "start",
"!!!!!!!!!!Application Start!!!!!!!!!!");
}
public void stop() {
Trace.log(Utility.ApplicationLogger, Level.SEVERE, AppHandler.class, "Stop",
"!!!!!!!!!!Application Stop!!!!!!!!!!");
}
public void activate() {
Trace.log(Utility.ApplicationLogger, Level.SEVERE, AppHandler.class, "activate",
"!!!!!!!!!!Application Activate!!!!!!!!!!");
}
public void deactivate() {
Trace.log(Utility.ApplicationLogger, Level.SEVERE, AppHandler.class, "deactivate",
"!!!!!!!!!!Application Deactivate!!!!!!!!!!");
}
}
2. Feature级的Lifecycle Event Listener
Feature1Handler.java 代码:
package mobile;
import com.sun.util.logging.Level;
import oracle.adfmf.feature.LifeCycleListener;
import oracle.adfmf.util.Utility;
import oracle.adfmf.util.logging.Trace;
public class Feature1Handler implements LifeCycleListener {
public Feature1Handler() {
super();
}
public void activate() {
Trace.log(Utility.ApplicationLogger, Level.SEVERE, Feature1Handler.class, "activate",
"!!!!!!!!!!Feature 1 Activate!!!!!!!!!!");
}
public void deactivate() {
Trace.log(Utility.ApplicationLogger, Level.SEVERE, Feature1Handler.class, "deactivate",
"!!!!!!!!!!Feature 1 Deactivate!!!!!!!!!!");
}
}
如果想要看到这些信息何时输出,请参考《使用Logger设置和查看Android应用的调试信息》。
没有评论:
发表评论