0

I can't quite figure out what the problem is here. Can anyone please help. I am developing the phonegap app using the phonegap 1.3.0.jar. Logcat shows the error at that point.

Below is the code:

public class Main extends DroidGap {

    ConnectivityManager connectivity;
    NetworkInfo activeNetwork;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setIntegerProperty("splashscreen", R.drawable.splash);

        connectivity  = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
        activeNetwork = connectivity.getActiveNetworkInfo(); 

        if(activeNetwork != null) {
            if(activeNetwork.getType() == ConnectivityManager.TYPE_WIFI)
            {Toast.makeText(this,activeNetwork.getTypeName(), Toast.LENGTH_SHORT).show();
            super.loadUrl("url", 1000);}

            else if(activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) 
            {Toast.makeText(this, activeNetwork.getTypeName(), Toast.LENGTH_SHORT).show();
            super.loadUrl("url", 1000);}    
        }//Connected to the Internet

        else {
            super.loadUrl("file:///android_asset/www/index.html", 1000);}       
        //No Internet Connection
    }

     public void onReceivedError( int errorCode, String description, String failingUrl)
        {
            super.loadUrl("file:///android_asset/www/index.html", 1000);
        //Server down.  
        }
}

And the logcat error:

--------- beginning of crash
11-25 10:27:13.000  9934  9934 E AndroidRuntime: FATAL EXCEPTION: main
11-25 10:27:13.000  9934  9934 E AndroidRuntime: Process: com.app.tradelance, PID: 9934
11-25 10:27:13.000  9934  9934 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.phonegap.CallbackServer.sendJavascript(java.lang.String)' on a null object reference
11-25 10:27:13.000  9934  9934 E AndroidRuntime:    at com.phonegap.DroidGap$LinearLayoutSoftKeyboardDetect.onMeasure(DroidGap.java:1699)
11-25 10:27:13.000  9934  9934 E AndroidRuntime:    at android.view.View.measure(View.java:18794)
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • at `LinearLayoutSoftKeyboardDetect.onMeasure`... Does your device have a keyboard? – OneCricketeer Nov 25 '16 at 06:09
  • No, the device does not have any keyboard. Do think this would be the issue at hand. – Brian Abura Nov 25 '16 at 06:19
  • I do not know. The error exists within the phonegap library according to that stacktrace, so you may want to submit a bug report, if you can, to them – OneCricketeer Nov 25 '16 at 06:22
  • Let me give it a try. – Brian Abura Nov 25 '16 at 06:25
  • Or since the error exists at `CallbackServer.sendJavascript`, then your device does not support running Javascript (which is something you have to manually enable in Android WebView). I do not know what this `DroidGap` class you have extended does, though. – OneCricketeer Nov 25 '16 at 06:27
  • I used DroidGap to integrate Phonegap into my android application. So as to support phonegap apps – Brian Abura Nov 25 '16 at 06:35
  • Sure, that makes sense. It's just NullPointerExceptions quickly get flagged and closed here (as you can see), even though the issue doesn't appear to be related to your code. – OneCricketeer Nov 25 '16 at 06:37
  • PhoneGap 1.3.0 is ANCIENT. You should switch to the CLI workflow using PhoneGap 6.x instead. IIRC, Google will reject PhoneGap apps using < 4.x anyway. – Kerri Shotts Nov 26 '16 at 18:33

0 Answers0