【发布时间】:2016-01-11 09:31:15
【问题描述】:
我是科尔多瓦的新手。我正在为 PhoneGap 的 Android 中的视频捕获创建自定义插件。在我的 onActivityResult() 中,我正在获取捕获的视频。我在 onActivityResult() 中添加了一个回调,但它不起作用。
这是我的代码:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
final Mediatest that = this;
// TODO Auto-generated method stub
if (resultCode == cordova.getActivity().RESULT_OK) {
if (requestCode == REQUEST_VIDEO_CAPTURED) {
uriVideo = data.getData();
Toast.makeText(cordova.getActivity().getApplicationContext(),
uriVideo.getPath(), Toast.LENGTH_LONG).show();
that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
}
} else if (resultCode == cordova.getActivity().RESULT_CANCELED) {
uriVideo = null;
Toast.makeText(cordova.getActivity().getApplicationContext(),
"Cancelled!", Toast.LENGTH_LONG).show();
}
}
但是当我在 onActivityResult 之外添加回调方法时,它正在工作:
private void captureVideo(Long limit) {
this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
Intent intent = new Intent(
android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, limit);
cordova.setActivityResultCallback (this);
this.cordova.startActivityForResult((CordovaPlugin) this, intent, REQUEST_VIDEO_CAPTURED);
this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
}
吐司
Toast.makeText(cordova.getActivity().getApplicationContext(),
uriVideo.getPath(), Toast.LENGTH_LONG).show();
正在显示,但回调不起作用。我无法追踪问题。任何帮助将不胜感激。
【问题讨论】:
-
不幸的是不工作