这是我的 android 插件,我的一个方法需要一个上下文,有没有办法获得这个上下文?
public class GaziruPlugin extends CordovaPlugin{
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException
{
String value = args.getString(0);
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] imageByte = decoder.decodeBuffer(value);
Classlogic method = new Classlogic();
//this method requires a context type.
method.DoLogic(context,imageByte);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
}
我希望你能帮助我。谢谢
最佳答案
尝试将其放入您的插件中:
Context context=this.cordova.getActivity().getApplicationContext();
关于android - 如何在 phonegap 插件中获取上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25592206/