0
我做了一个插件,用于在javascript和原生java代码之间进行通信。但由于某种原因,我不得不立即返回到回调函数。反过来,我在java.now中完成实现后开始了一个异步方法,我想返回到我的javascript.Please告诉我如何去做。从科尔多瓦的java方法中调用javascript函数
我的Java代码是 -
public class MyPlugin extends CordovaPlugin
{
String fileName;
Context context;
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
// your init code here
}
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException
{
context=this.cordova.getActivity().getApplicationContext();
String myurl = args.getString(0);
if (action.equals("plugin1"))
{
new DownloadManager().execute(myurl);
callbackContext.success("Operation performed successfully!!");
return true;
}
callbackContext.error("error");
return false;
}
public class DownloadManager extends AsyncTask<String, String, String> {
@Override
public String doInBackground(String... arg0) {
downloadapk(arg0[0]);
installapk();
System.out.println("Download Complete");
return null;
//Here I want to return to javascript.How can I callback to the javascript function from //async method??
}
}
Thanx为您的答案。这对我帮助很大。 – megha 2014-09-22 05:54:20