0

I have a score system that counts how much question I answered in my quiz app. In onPause(), I write the count of played questions in database.

@Override
protected void onPause(){
    super.onPause();
    SpielDBOpenHandler sdb = new SpielDBOpenHandler(Allgemeinwissen.this);
    sdb.insert(3, fragencount, 3, 4);
}

That works fine.

I raise the score in an onClick method of a button:

fragencount += 1; 

Now, when I close the app via home button and reopen it and press back, it counts two times. When I totally close my app and open a new task of the app, it counts normally. What can I do?

EDIT:

The button listener looks like this:

ausw = (Button) findViewById(R.id.btAuswertung);
        ausw.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                  fragencount += 1
                      ...
            }

EDIT2:

Ok I know know that onPause() isCalled when I press the home button to temporarily close the app and again when I am in the app again and press the back button. Is there a way that onPause() isn´t called when I temporarily close the app via home button?

4

0 回答 0