मैं खत्म हो गया है, यह परिणाम गतिविधि के लिए ले जाएगा सौंपा मिनट के बाद जो पूरे gameactivity जहां में आप के रूप में ज्यादा सवाल सौंपा मिनट के भीतर आप कर सकते हैं का जवाब चाहिए के लिए एक टाइमर है एक प्रश्नोत्तरी एप्लिकेशन ..गतिविधि अभी भी खत्म होने के बाद जारी है();
है जो आपका स्कोर दिखाता है। बैक प्रेस पर, मैंने एक चेतावनी संवाद बनाया जो पूछता है कि क्या आप मुख्य मेनू पर वापस जाना चाहते हैं। यदि हाँ पर क्लिक किया गया है, तो पृष्ठ को मुख्य मेनू पर वापस जाना चाहिए और गेमएक्टिविटी को रोकना/मारना चाहिए।
हालांकि, जब मैं "हाँ" पर क्लिक करता हूं, तो यह मुख्य मेनू पर वापस जायेगा, लेकिन जब भी आप एप्लिकेशन में कहीं भी हों, तो परिणाम अभी भी पिछले गेमएक्टिविटी से दिखाए जाएंगे। वास्तव में gameactivity समाप्त हो सकता है मैं hadnt, .. यहाँ टाइमर और मेरी गतिविधि से वापस प्रेस टुकड़ा है:
new CountDownTimer(seconds, 1000) {
public void onTick(long millisUntilFinished) {
timer.setText("Seconds left: " + millisUntilFinished/1000);
}
public void onFinish() {
Intent intent = new Intent(GameActivityAddition.this, Score.class);
intent.putExtra("totalscore", score);
intent.putExtra("numberquestions", rowId);
intent.putExtra("d", difficulty);
db.close();
startActivity(intent);
}
}.start();
@Override
public void onBackPressed() {
AlertDialog.Builder abuilder = new Builder(GameActivityAddition.this);
abuilder.setMessage("Return to Main Menu?");
abuilder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent main = new Intent(GameActivityAddition.this, Main.class);
startActivity(main);
finish();
}
});
abuilder.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alert = abuilder.create();
alert.show();
}
आपके परिणाम गतिविधि में सेट किया गया डेटा हो सकता है जब आप गतिविधि को समाप्त करते हैं तो आपको साफ़ नहीं किया जाता है, जिससे आप फिर से गतिविधि पर जाते समय पुराने डेटा देख सकते हैं। – Hiral
आप गिनती बंद नहीं कर रहे हैं। – user996428
मुझे लगता है, बस अनुमान लगाएं, उलटी गिनती टाइमर एक थ्रेड की तरह काम करता है, जो कि जब आप फिनिश() कॉल करते हैं तब भी चलते रहते हैं। इसके चलने को नियंत्रित करने के लिए टाइमर में एक बूलियन चर जोड़ने की कोशिश करें। – Huang