Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8535989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:33:40+00:00 2026-06-11T10:33:40+00:00

I am new to PhoneGap and I am able to implement the basic app

  • 0

I am new to PhoneGap and I am able to implement the basic app with PhoneGap, now to enhance it further, I want to connect PhoneGap with Android Activities, basically what I plan is to call startActivity() method using a javascript function.

I tried Communication between Android Java and Phonegap Javascript?

but I failed to call an activity, causing force close error.
Do help me out, awaiting a reply!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:33:41+00:00Added an answer on June 11, 2026 at 10:33 am

    Any Java Native code call be called without using any plugin as following.

    Follow The following Steps.

    1. Replace the following code with your existing DroidGap Activity.

      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          super.init(); // Calling this is necessary to make this work
          appView.addJavascriptInterface(this, "MainActivity");
      
          /* "this" points the to the object of the current activity. "MainActivity" is used to refer "this" object in JavaScript as in Step 3. */
      
          super.loadUrl("file:///android_asset/www/index.html");
      }
      
    2. Add the custom function in current (this) activity as following.

      public void customFunctionCalled() {
          Log.e("Custom Function Called", "Custom Function Called");
      }
      
    3. Now call this function from your HTML/JavaScript code as following.

      <script type="text/javascript">
          function callNewActivity() {
              window.MainActivity.customFunctionCalled();
          }
      </script>
      

    This will call customFunctionCalled() in MainActivity.

    Tested Environment
    Eclipse – 3.7.2
    Android 2.2 Emulator
    PhoneGap – 2.0.0

    Please provide your comments here to improve blogs post.
    http://phonegapexplorers.blogspot.in/2012/08/call-native-java-code-phonegap-android.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to make an iphone and android app using php.
I'm new to phoneGap, and i'm trying to implement a webview in android with
I'm new to Phonegap and I want to develop a Phonegap application for Android..
I am new to phonegap and android, I have create a hello world application
I am new to PhoneGap I want to know whether PhoneGap is only for
I am using phonegap to develop my android application.I want to show google chart
I am new to phonegap.I am using jquery mobile with html5 for developing android
I just started with PhoneGap development and have my first sample android app running
I'm using PhoneGap to build an Android app. Using either jQuery or Zepto, I'm
I´m new to PhoneGap/CoffeeScript trying to get a Hello World App running in iOS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.