Application
<h3>概述</h3>
<p>在APP Application中定义公用处理内容,避免调用接口时重复初始化对象</p>
<h3>1.定义对象方法</h3>
<pre><code class="language-java">
private LoginRequest loginRequest;
public LoginRequest getLoginRequest() {
if (loginRequest == null)
loginRequest = new LoginRequest();
return loginRequest;
}
private RecognizeRequest recognizeRequest;
public RecognizeRequest getRecognizeRequest() {
if (recognizeRequest == null)
recognizeRequest = new RecognizeRequest();
return recognizeRequest;
}
private KnowledgeRequest knowledgeRequest;
public KnowledgeRequest getKnowledgeRequest() {
if (knowledgeRequest == null)
knowledgeRequest = new KnowledgeRequest();
return knowledgeRequest;
}
public void init() {
LabelDataMgr.get().init();
QuestionSearchMgr.get().init();
QuestionAnswerMgr.get().init();
}</code></pre>
<p><strong>备注:在onCreate时调用init(),页面使用时通过application.getRecognizeRequest().xx请求登录、识别、知识点视频</strong></p>
<h3>3.在退出系统onExit时调用退出登录</h3>
<pre><code class="language-java"> getLoginRequest().exitLogin(context, callback);</code></pre>
<h4>2.1 ILabelDataCallback介绍</h4>
<p>ILabelDataCallback是数据结果的返回,有三个方法onLabelSuccess, onWordInfoCallback和onLabelFail;</p>
<p><strong>方法名称:</strong></p>
<pre><code class="language-java">
getLoginRequest().exitLogin(context, callback);
</code></pre>