I'm getting the following stack trace and after searching for quite some time now, I still have no idea what is causing it. Quite new to this.

I found most of the code on the internet and modified it to fit my own purposes, so this might be causing some of the problems.

```
01-11 22:20:02.608: W/dalvikvm(573): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
01-11 22:20:02.628: E/AndroidRuntime(573): FATAL EXCEPTION: main
01-11 22:20:02.628: E/AndroidRuntime(573): java.lang.IllegalStateException: Could not execute method of the activity
01-11 22:20:02.628: E/AndroidRuntime(573):  at android.view.View$1.onClick(View.java:3039)
01-11 22:20:02.628: E/AndroidRuntime(573):  at android.view.View.performClick(View.java:3480)
01-11 22:20:02.628: E/AndroidRuntime(573):  at android.view.View$PerformClick.run(View.java:13983)
01-11 22:20:02.628: E/AndroidRuntime(573):  at android.os.Handler.handleCallback(Handler.java:605)
01-11 22:20:02.628: E/AndroidRuntime(573):  at android.os.Handler.dispatchMessage(Handler.java:92)
01-11 22:20:02.628: E/AndroidRuntime(573):  at android.os.Looper.loop(Looper.java:137)
01-11 22:20:02.628: E/AndroidRuntime(573):  at android.app.ActivityThread.main(ActivityThread.java:4340)
01-11 22:20:02.628: E/AndroidRuntime(573):  at java.lang.reflect.Method.invokeNative(Native Method)
01-11 22:20:02.628: E/AndroidRuntime(573):  at java.lang.reflect.Method.invoke(Method.java:511)
01-11 22:20:02.628: E/AndroidRuntime(573):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-11 22:20:02.628: E/AndroidRuntime(573):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-11 22:20:02.628: E/AndroidRuntime(573):  at dalvik.system.NativeStart.main(Native Method)
01-11 22:20:02.628: E/AndroidRuntime(573): Caused by: java.lang.reflect.InvocationTargetException
01-11 22:20:02.628: E/AndroidRuntime(573):  at java.lang.reflect.Method.invokeNative(Native Method)
01-11 22:20:02.628: E/AndroidRuntime(573):  at java.lang.reflect.Method.invoke(Method.java:511)
01-11 22:20:02.628: E/AndroidRuntime(573):  at android.view.View$1.onClick(View.java:3034)
01-11 22:20:02.628: E/AndroidRuntime(573):  ... 11 more
01-11 22:20:02.628: E/AndroidRuntime(573): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to nl.hees.quiz.QuizApplication
01-11 22:20:02.628: E/AndroidRuntime(573):  at nl.hees.quiz.MainActivity.onClick(MainActivity.java:45)
01-11 22:20:02.628: E/AndroidRuntime(573):  ... 14 more

```

**MainActivity.java**

```
public class MainActivity extends Activity {
    private Button tfBtn, mcBtn, sqBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        tfBtn = (Button) findViewById(R.id.button1);
        mcBtn = (Button) findViewById(R.id.button2);
        sqBtn = (Button) findViewById(R.id.button3);
    }

    public void onClick(View v) {
        Intent i;

        switch(v.getId()) {
        case R.id.button1:

            i = new Intent(this, TfActivity.class);
            startActivity(i);
            break;
        case R.id.button2:
            //Retrieve questions//
            List<Question> questions = getQuestionsFromDb();

            //Initialize game//
            Game g = new Game();
            g.setQuestions(questions);
            g.setNumRounds(getNumQuestions());
            ((QuizApplication)getApplication()).setCurrentGame(g);

            //Start game//
            i = new Intent(this, McActivity.class);
            startActivity(i);
            break;
        case R.id.button3:

            i = new Intent(this, SqActivity.class);
            startActivity(i);
            break;
        case R.id.button4:
            finish();
            break;
        }
    }

    private List<Question> getQuestionsFromDb() throws Error {
        int diff = getDifficultySettings();
        int numQuestions = getNumQuestions();

        DBHelper helper = new DBHelper(this);
        try {
            helper.createDataBase();
        } catch(IOException ioe) {
            throw new Error("Kan database niet aanmaken");
        }
        try {
            helper.openDataBase();
        } catch(SQLException sqle) {
            throw sqle;
        }
        List<Question> questions = helper.getQuestions(diff, numQuestions);
        helper.close();
        return questions;
    }

    private int getDifficultySettings() {
        SharedPreferences settings = getSharedPreferences(Constants.SETTINGS, 0);
        int diff = settings.getInt(Constants.DIFFICULTY, Constants.MEDIUM);
        return diff;
    }

    private int getNumQuestions() {
        SharedPreferences settings = getSharedPreferences(Constants.SETTINGS, 0);
        int numRounds = settings.getInt(Constants.NUM_ROUNDS, 20);
        return numRounds;
    }
}

```