Phonegap 2.3.0 and the ForegroundCamera plugin

≡放荡痞女 提交于 2019-12-21 20:07:05

问题


I'm using Phonegap 2.3.0 and the new ForegroundCamera plugin from Google Code.. I followed the instructions carefully, and in my Eclipse setup I got the following errors when validating the project:

  • Cannot cast from ForegroundCameraLauncher to Plugin
  • ctx cannot be resolved or is not a field (x2)
  • R cannot be resolved to a variable (x4)
  • The method success(PluginResult, String) is undefined for the type ForegroundCameraLauncher

Now, I solved the first three of the above errors by updating some deprecated code lines (I hope I got it solved - it doesn't show the errors anymore)..

The first error was corrected by changing Plugin to CordovaPlugin in the line "import org.apache.cordova.api.Plugin;" in ForegroundCameraLauncher.java. ctx was replaced with cordova.getActivity() at those two places, where it caused trouble. This thing with R was fixed by doing some library changes which made it create an R object (sorry, I don't know how to explain this the right way, as I'm not too experienced with Eclipse yet).

With the last one of the four error messages, I tried to make a temporary fix by commenting out those two lines in ForegroundCameraLauncher.java (the lines with "this.success"...). But when taking a picture in my app, it crashes the whole thing upon returning from the camera instance..

Anyone know what's going on? I'd really be happy to get a few pointers here :)

The last error is obviously the one you should be focusing on ;) I just wanted to include some of the error fixing process, if others have experienced the same errors.


回答1:


See this commit to see what has changed in Cordova: https://github.com/apache/cordova-android/commit/205215d409c4f75e958a9c09c0b4a38bd9a859ac

Replace
this.success(new PluginResult(PluginResult.Status.OK, getRealPathFromURI(uri, this.ctx)), this.callbackId);
with
this.callbackContext.success(getRealPathFromURI(uri, cordova));.

Update the execute function as per that commit, and update takePicture.

After that I have the ForgroundCamera plugin working with Cordova 2.3. Going to do some more testing and clean up now.




回答2:


We have just updated Foreground Camera Plugin to work with Phonegap 2.4.0 and we are working on Foreground Gallery Plugin too. Please see http://code.google.com/p/foreground-camera-plugin/ and http://code.google.com/p/foreground-gallery-plugin/, and let us know (post an issue) if you have any problem.

See ya!



来源:https://stackoverflow.com/questions/14755336/phonegap-2-3-0-and-the-foregroundcamera-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!