从CordovaPlugin打开活动 [英] open an activity from a CordovaPlugin
本文介绍了从CordovaPlugin打开活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经写了CordavaPlugin派生类。
I have written a CordavaPlugin derived class.
public class ShowMap extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray args,
CallbackContext callbackContext) throws JSONException {
if (action.compareTo("showMap") == 0)
{
String message = args.getString(0);
this.echo(message, callbackContext);
Intent i = new Intent();
return true;
}
return false;
}
private void echo(String message, CallbackContext callbackContext) {
if (message != null && message.length() > 0) {
callbackContext.success(message);
} else {
callbackContext.error("Expected one non-empty string argument.");
}
}
}
我从这个类要打开一个新的活动。 如何获得访问PhoneGap的基础类的原始环境?
I want from this class to open a new activity. How do I get access to the original context of the phonegap based class?
推荐答案
尝试为:
Context context=this.cordova.getActivity().getApplicationContext();
//or Context context=cordova.getActivity().getApplicationContext();
Intent intent=new Intent(context,Next_Activity.class);
context.startActivity(intent);
//or cordova.getActivity().startActivity(intent);
和确保你已经在的AndroidManifest.xml
这篇关于从CordovaPlugin打开活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文