Skip to content

getApplicationContext from Capacitor Plugin #5688

Answered by w-mazed
w-mazed asked this question in Q&A
Discussion options

You must be logged in to vote

Thank's @robingenz, I just tried the code that you provided, but still have the same error

package com.mycompany.mypackage;

import com.getcapacitor.JSObject;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
import com.getcapacitor.annotation.CapacitorPlugin;

@CapacitorPlugin(name = "MyPackage")
public class MyPackagePlugin extends Plugin {

    private MyPackage implementation = new MyPackage(this.getActivity().getApplicationContext());

    @PluginMethod
    public void echo(PluginCall call) {
        String value = call.getString("value");

        JSObject ret = new JSObject();
        ret.put("value", implementation.echo(value…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@robingenz
Comment options

@w-mazed
Comment options

Answer selected by w-mazed
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants