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 8948371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:58:10+00:00 2026-06-15T12:58:10+00:00

I am trying to implement the workaround provided by Chris found here to allow

  • 0

I am trying to implement the workaround provided by Chris found here to allow a PhoneGap/Cordova-built Android app to make AJAX HTTPS requests to a server with a self-signed SSL certificate. I am using PhoneGap/Cordova 2.1.0, whereas Chris was using 1.7.0. I can create the MyWebViewClient class without issue. However, when I add this line of code…

this.setWebViewClient(this.appView, new MyWebViewClient(this));

…to the MainActivity class’ overridden init() method, I receive this error:

The method setWebViewClient(CordovaWebView, MyWebViewClient) is undefined for the type MainActivity

Here is my code for MyWebViewClient.java:

package [packagename];

import android.net.http.SslError;
import android.webkit.SslErrorHandler;
import android.webkit.WebView;
import org.apache.cordova.CordovaWebViewClient;
import org.apache.cordova.DroidGap;

public class MyWebViewClient extends CordovaWebViewClient {

    public class MyWebViewClient(DroidGap ctx) {
        super(ctx);
    }

    @Override
    public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
        handler.proceed();
    }
}

Here is my code for MainActivity.java:

package [packagename];

import android.os.Bundle;
import org.apache.cordova.*;

public class MainActivity extends DroidGap {

    @Override
    public void init() {
        super.init();
        this.setWebViewClient(this.appView, new MyWebViewClient(this)); // Error occurs here
    }

    @Override
    public void onCreate(bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setBooleanProperty("keeprunning", false);
        super.loadUrl("file:///android_asset/www/index.html");
    }
}

I do not have enough reputation, otherwise I would have just commented on Chris’ answer. Also, I am not looking for a jQuery solution (I already know I can make a $.ajax() call to avoid this issue, but I am trying to keep jQuery out of my app).

Any ideas? Your help is greatly appreciated!

Edit: Please see my comments below before responding.

  • 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-15T12:58:12+00:00Added an answer on June 15, 2026 at 12:58 pm

    This can be fixed as below on later Cordova versions (I’m using 2.2). As mentioned, it fails at onPageStarted() – this is because it’s expecting an appView, which is null so you get a NullPointerException. Setting the appView seems to fix it eg

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.init();
    
        CordovaWebViewClient webViewClient = new CustomWebViewClient(this);
        webViewClient.setWebView(this.appView);
        this.appView.setWebViewClient(webViewClient);
    
        super.loadUrl("file:///android_asset/www/index.html");
    
    }
    

    Note that the super.init() is also needed

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

Sidebar

Related Questions

Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
I'm trying to implement a workaround to the problem of using AJAX with multi-part
Trying to implement google C2DM service. registrationIntent.putExtra(app, PendingIntent.getBroadcast(context,0,new Intent(), 0)); registrationIntent.putExtra(sender,example@gmail.com); context.startService(registrationIntent); Almost every
Trying to implement a search similar to here .This searches properties based on city,locality,property
I am trying to implement a finger detection, which link is given here .
I'm trying to implement Tasks in my Application. Here's the sample code: There's one
I'm trying implement A* Start path finding in my games(which are written with JavaScript,
I am trying implement a most recent widget into my tumblr post. So far,
Trying to implement LoaderManager + CursorLoader. In onFinish method adapter should swap its cursor
Trying to implement 3-layer (not: tier, I just want to separate my project logically,

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.