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

  • SEARCH
  • Home
  • 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 8762177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:27:49+00:00 2026-06-13T15:27:49+00:00

I am trying to get a call back from my Web View when a

  • 0

I am trying to get a call back from my Web View when a table row is clicked in the html page. My activity is as below:

 public class LocalizationTestActivity extends Activity {



/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
    WebView webView = new WebView(this);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT));
    JavaScriptInterface javaScriptInterface=new JavaScriptInterface(this);
    webView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
    Vector<Employee> test=new Vector<Employee>();
    for (int i=1;i<20;i++){
        Employee employee=new Employee();
        employee.setId(i);
        employee.setName("Norton - "+i);
        employee.setAddress("Indiranagar - " +i);
        test.add(employee);
    }
    javaScriptInterface.setDashboardList(test);

    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {

            view.loadUrl("javascript:populateData()");
        }

    });

    webView.loadUrl("file:///android_asset/html/test2.html");
    linearLayout.addView(webView);
    setContentView(linearLayout);
}
}

My Java script class is as below:

public class JavaScriptInterface {
private Context mContext;
private Vector employeeList;

    /** Instantiate the interface and set the context */
    JavaScriptInterface(Context c) {
        mContext = c;
    }

    /** Show a toast from the web page */
    public void callBack(String toast) {

        int index=Integer.parseInt(toast);
        Intent intent=new Intent(mContext, SampleActivity.class);

        if(employeeList!=null && index<employeeList.size()){
            Employee employee=(Employee) employeeList.elementAt(index);
            intent.putExtra("value", "1");
            intent.putExtra("name", employee.getName());
            intent.putExtra("address", employee.getAddress());
        }
        mContext.startActivity(intent);
    }


    public void setEmployeeList(Vector employeeList) {
        this.employeeList= employeeList;
    }
    }

The call back works fine. But when i try accesing the employeeList from callBack method the list is always null though i am setting the list value from my activity class. Am i missing on something? Could someone kindly help me with this.

  • 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-13T15:27:50+00:00Added an answer on June 13, 2026 at 3:27 pm

    Change

    webView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
    

    to

    webView.addJavascriptInterface(javaScriptInterface, "Android");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is my program and I am trying to get the call stack when
I have the code below: from the getData function im trying to call get_xml
I'm trying to get a JSON from a webservice with javascript $.Ajax call. <script
I am trying to get the code found here: http://snipplr.com/view/26643/mbprogresshud-with-an-asynchronous-nsurlconnection-call/ to work in my
I am trying to call a web service from an ajax jquery. It is
I'm trying to parse JSON result from an Ajax call to .NET web service
I am trying to call a web service from an metro application. I am
I am trying to call an ASMX from jQuery using JSON and get a
I'm trying to call Get-WMIObject (gwmi) on multiple computers selected via Get-ADComputer as a
I am trying to get the program to call up the current date, add

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.