Fra*_*ebu 39 android cordova cordova-plugins
这是我的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;
}
Run Code Online (Sandbox Code Playgroud)
}
我希望你能帮助我.谢谢
mal*_*rre 88
试着把它放到你的插件中:
Context context=this.cordova.getActivity().getApplicationContext();
Run Code Online (Sandbox Code Playgroud)