AIDataService cannot be applied

Saksham Dubey :
 final ai.api.android.AIConfiguration configuration = new ai.api.android.AIConfiguration("Client access token", AIConfiguration.SupportedLanguages.English,

           ai.api.android.AIConfiguration.RecognitionEngine.System);

    aiService = AIService.getService(this, configuration);
    aiService.setListener((AIListener) this);

    final AIRequest aiRequest = new AIRequest();
    final AIDataService aiDataService;
    aiDataService = new AIDataService(configuration);

The error is in the last line of the code. i.e :- aiDataService = new AIDataService(configuration); the error says -

'AIDataService(android.content.Context, ai.api.android.AIConfiguration)' in 'ai.api.android.AIDataService' cannot be applied to '(ai.api.android.AIConfiguration)'

Saksham Dubey :

The error is caused because AIDataService does not have any context in its syntax. To resolve the problem

declare

private Context context;

and

context = getApplicationContext();

now the syntax will be

final AIDataService aiDataService = new AIDataService(context, configuration);

Now there will be no error and it works fine.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=107062&siteId=1