Friday, August 31, 2012

Call Native Java Code - PhoneGap Android


This blog post moved here.

Please refer here for more details.

8 comments:

  1. @Override is not working for
    >>
    @Override
    public void customFunctionCalled() {
    <<

    Hence total code snippet is waste... :(

    ReplyDelete
    Replies
    1. You can test code by removing the @Override above the customFunctionCalled().

      Hope this help you to run the code.

      Delete
  2. Not work for me, what's wrong with my code sir?
    this is my code:

    public class MainActivity extends DroidGap {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.init();
    appView.addJavascriptInterface(this,"MainActivity");
    super.loadUrl("file:///android_asset/www/index.html");

    }

    public void customFunctionCalled() {
    Log.e("Custom Function Called", "Custom Function Called");
    }
    }

    ReplyDelete
    Replies
    1. Hello I Gde Dian Adi Juliartha,

      Sorry for delay in reply.

      You can check here the updated/Working code.

      http://stackoverflow.com/questions/7292553/how-to-call-an-android-activity-from-phonegap/

      Please feel free to let me know, If still it's not working.

      Thank You.

      Delete
    2. hello Avtarsingh,

      i see your new post, but still failing for me

      i'm so noob :S . have u got a simply project full working ?

      my mail is kimera_77@hotmail.com

      ty men

      Delete
    3. i doesn't work in 2.7.0
      .. could yo please sent me a sample working project?
      my mail id
      maniya0205@gmail.com

      Delete
  3. I applied this code in my project and it worked but when i run my Samsung S4 that Android version 4.2.2 then I get an error this are "Uncaught TypeError: Cannot call method 'customFunctionCalled' of undefined"

    please help any one.

    ReplyDelete
  4.  I appreciate your efforts of writing this blog content, it’s really a beneficial and informative post. Good work!! Keep going on.
    PhoneGap Development Company Texas

    Hire PhoneGap Developers

    ReplyDelete