Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Registering capacitor plugins in java with FragmentActivity

$
0
0

I’m working on a capacitor/electron project. I have written a plugin of my own and also I am using a few community plugins. This is my MainActivity class. I have one big problem with the line that starts out ‘this.init…’ . The error is shown below. How do I get rid of this error?

My second problem is weather or not to try to register the PluginURLPost plugin with an ‘add’ statement. That’s not as big of a problem because I think I can just try it out both ways and whichever works I go with.

    package org.theguy.GptEtc;

    import android.os.Bundle;
    import org.theguy.GptEtc.PluginURLPost;

    import com.getcapacitor.BridgeActivity;
    import com.getcapacitor.Plugin;

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


    public class MainActivity extends BridgeActivity {

        @Override
        public void onCreate(Bundle savedInstanceState) {
            registerPlugin(PluginURLPost.class); // <-- my plugin 
             
            super.onCreate(savedInstanceState); 
            this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{ // <-- how to stop error
                // Additional plugins you've installed go here
                // Ex: add(TotallyAwesomePlugin.class);
                add(SpeechRecognition.class); // <-- community plugin 
                //add(PluginURLPost.class) // <-- this?
            }});
             
        }

    }

I get this error:

    'init()' has private access in 'androidx.fragment.app.FragmentActivity'

I hope this makes sense. Any help would be appreciated.

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



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