Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48979

Add capacitor speech recognition to android mainactivity

$
0
0

I’m trying to use capacitor speech recognition, they said on android it need this code in order to be working on android

import com.getcapacitor.community.speechrecognition.SpeechRecognition;

public class MainActivity extends BridgeActivity {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(
        savedInstanceState,
        new ArrayList<Class<? extends Plugin>>() {

          {
            // Additional plugins you've installed go here
            // Ex: add(TotallyAwesomePlugin.class);
            add(SpeechRecognition.class);
          }
        }
      );
  }
}

i’ve added it like this

package io.ionic.starter;

import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import com.getcapacitor.community.speechrecognition.SpeechRecognition;
import java.util.ArrayList;

public class MainActivity extends BridgeActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Initializes the Bridge
        this.init(
                savedInstanceState,
                new ArrayList<Class<? extends Plugin>>() {

                    {
                        // Additional plugins you've installed go here
                        // Ex: add(TotallyAwesomePlugin.class);
                        add(SpeechRecognition.class);
                    }
                }
        );
    }
}

but it gives me an error like this

error: package com.getcapacitor.community.speechrecognition does not exist
import com.getcapacitor.community.speechrecognition.SpeechRecognition;

anyone knows how to fix this?

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 48979

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>