私はアンドロイドSDKのチュートリアルhereに従っています。サービスリスナーを設定すると、ビルド時にエラーが発生します。Androidライブラリ実装の問題
エラーとコード(OnCreateの下MainActivity内側):
aiService = AIService.getService(this, config);
aiService.setListener(this);
がエラー:
Error: method setListener in class AIService cannot be applied to given types;
required: AIListener
found: MainActivity
reason: actual argument MainActivity cannot be converted to AIListener by method invocation conversion
私はここに、クラスに実装しました
public class MainActivity extends AppCompatActivity implements AIListener {
AIListenerクラス
public interface AIListener {
void onResult(AIResponse result); // here process response
void onError(AIError error); // here process error
void onAudioLevel(float level); // callback for sound level visualization
void onListeningStarted(); // indicate start listening here
void onListeningCanceled(); // indicate stop listening here
void onListeningFinished(); // indicate stop listening here
}
AIListenerはMainActivityによって正しく実装されていますが、MainActivityでこれらのメソッドをオーバーライドしていても、Androidスタジオではメソッドが使用されていないことが表示されます。
私は自分の質問を編集しましたが、私はそれを実装しました。だから、これはとても混乱しています! –
AIListenerは別ファイルですが、これはすべてMainActivityの下にあります。 –
私は間違ったエラーを打ちました。それは問題で修正されました。 –