Hi,

I have a problem with Android 3.2. The following line causes the
NullPointer exception under Android 3.2:

        btnAbout.setOnClickListener(aboutSelected);

In the debugger I can see that aboutSelected is NOT null. The same
code runs without problems under Android 4.0.3 and 2.3.3.

Does anybody knows how to solve that problem ?

Thanks
Andre


Code:
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        GridView gridView = (GridView) findViewById(R.id.hersteller);
        gridView.setAdapter(new ImageAdapter(this));

        gridView.setOnItemClickListener(herstellerSelected);

        Button btnSuchen = (Button) findViewById(R.id.btnSuche);
        btnSuchen.setOnClickListener(sucheSelected);

        Button btnAbout = (Button) findViewById(R.id.btnAbout);
        btnAbout.setOnClickListener(aboutSelected);

//        Button btnKonfiguration = (Button)
findViewById(R.id.btnKonfiguration);
//        btnKonfiguration.setOnClickListener(konfigurationSelected);

        SQLiteDatabase.loadLibs(this);

        dbAdapter myDbAdapter = new dbAdapter(this);
        boolean dbExist = myDbAdapter.checkDatabase();
        if (!dbExist) try {
                myDbAdapter.createDatabase();
        }
        catch (IOException e) {
                throw new Error ("Datenbank kann nicht kopiert werden");
        }
        myDbAdapter.close();

        SharedPreferences einstellungen =
PreferenceActivity.getEinstellungen(this);
        String land = einstellungen.getString("ListLand", "");
        if (land.equals("")) {
                land = getString(R.string.Deutschland);
                SharedPreferences.Editor editor = einstellungen.edit();
                editor.putString("ListLand", land);
                editor.commit();
        }

        if (isOnline()) {
                //
        } else {
                // Keine Internetverbindung => Warnmeldung anzeigen !
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
 
builder.setMessage(getString(R.string.KeineInternetverbindung));
                builder.setCancelable(false);
                builder.setPositiveButton(getString(R.string.Ok), new
DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int 
which) {
                                        dialog.cancel();
                                }
                        });
                AlertDialog alert = builder.create();
                alert.show();
        }
    }


Trace:
05-08 06:35:47.770: E/AndroidRuntime(572): FATAL EXCEPTION: main
05-08 06:35:47.770: E/AndroidRuntime(572): java.lang.RuntimeException:
Unable to start activity ComponentInfo{com.wiget.autokatalog/
com.wiget.autokatalog.AutokatalogActivity}:
java.lang.NullPointerException
05-08 06:35:47.770: E/AndroidRuntime(572):      at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1815)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
1831)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
android.app.ActivityThread.access$500(ActivityThread.java:122)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
android.os.Handler.dispatchMessage(Handler.java:99)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
android.os.Looper.loop(Looper.java:132)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
android.app.ActivityThread.main(ActivityThread.java:4123)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
java.lang.reflect.Method.invokeNative(Native Method)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
java.lang.reflect.Method.invoke(Method.java:491)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
dalvik.system.NativeStart.main(Native Method)
05-08 06:35:47.770: E/AndroidRuntime(572): Caused by:
java.lang.NullPointerException
05-08 06:35:47.770: E/AndroidRuntime(572):      at
com.wiget.autokatalog.AutokatalogActivity.onCreate(AutokatalogActivity.java:
47)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
android.app.Activity.performCreate(Activity.java:4397)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1048)
05-08 06:35:47.770: E/AndroidRuntime(572):      at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1779)
05-08 06:35:47.770: E/AndroidRuntime(572):      ... 11 more

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to