如何让你的环境在你的PhoneGap插件 [英] How to get your context in your phonegap plugin
本文介绍了如何让你的环境在你的PhoneGap插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的插件Android和我的方法之一,需要一个背景下,有没有一种方法,我怎么能得到这样的背景下?
This is my plugin for android and one of my method requires a context, Is there a way how can I get this context?
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;
}
}
我希望你能帮助我。谢谢
I hope you can help me. Thanks
推荐答案
试图把这个变成你的插件:
try to put this into your plugin:
Context context=this.cordova.getActivity().getApplicationContext();
这篇关于如何让你的环境在你的PhoneGap插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文