E/AndroidRuntime﹕ FATAL EXCEPTION: main

Caused by: java.lang.NullPointerException
    at android.app.Activity.findViewById(Activity.java:1884)
    at net.dominik.genpush.settings.<init>(settings.java:23)

You’re calling findViewById() too early when initializing an activity settings object, likely a member variable. The code you posted doesn’t show that.

You can call activity functions really only in onCreate() or later.

Also put the findViewById() after setContentView() so it can actually return something other than null.

Leave a Comment