我创建了一个PhoneGap
插件为Android发送email
。PhoneGap android:越来越不能创建处理程序内部线程没有调用Looper.prepare()
public PluginResult execute(String action, JSONArray args, String callbackId) {
try {
// i want to call a function from other class so i did the
// below, but it is throwing the above said error...
WebActivity wb = new WebActivity();
wb.createExternalStoragePrivateFile(img);
//sending email code here
}
}
在上面的代码中,同时访问另一个类的功能,我得到的错误:
cannot create
handler
inside thread that has not calledLooper.prepare()
error.
什么是调用函数的正确方法?
thanx的回复,在createExternalStoragePrivateFile()函数即时复制资产文件夹中的文件到SD卡上的外部文件, 如果我创建另一个独立的静态类,那么如何访问assets文件夹中的文件..? – 2011-12-20 08:49:59
传递上下文:'createExternakStoragePrivateFile(Context)'。然后你就可以访问'AssetManager'并复制文件。 – inazaruk 2011-12-20 09:24:39
Thanku inazaruk,它工作:) – 2011-12-21 04:15:55