Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. private void dialogSettings() {
  2. final Dialog dialog = new Dialog(this, R.style.dialog_style);
  3. dialog.setContentView(R.layout.dialog_settings);
  4. final CheckBox sound = (CheckBox) dialog.findViewById(R.id.checkBoxSound);
  5. final CheckBox vibration = (CheckBox) dialog.findViewById(R.id.checkBoxVibration);
  6. final SharedPreferences pref = getSharedPreferences("SETTINGS", 0);
  7. sound.setChecked(pref.getBoolean("SOUND", true));
  8. vibration.setChecked(pref.getBoolean("VIBRATION", true));
  9. Button buttonSave = (Button) dialog.findViewById(R.id.buttonSave);
  10. buttonSave.setOnClickListener(new OnClickListener() {
  11. public void onClick(View v) {
  12. SharedPreferences.Editor editor = pref.edit();
  13. editor.putBoolean("SOUND", sound.isChecked());
  14. editor.putBoolean("VIBRATION", vibration.isChecked());
  15. editor.commit();
  16. dialog.dismiss();
  17. }
  18. });
  19. dialog.show();
  20. }
  21.  
  22. private boolean SOUND;
  23.  
  24. public void onCreate(Bundle savedInstanceState) {
  25. super.onCreate(savedInstanceState);
  26. setContentView(R.layout.game_normal_layout);
  27. SharedPreferences pref = getSharedPreferences("SETTINGS", 0);
  28. SOUND = pref.getBoolean("SOUND", true);
  29. ....
  30. }
  31.  
  32. private void evaluateAnswer() {
  33. if(correct) {
  34. if(SOUND) { // LINE 259
  35. ding.seekTo(0);
  36. ding.start();
  37. }
  38. ...
  39. }
  40.  
  41. java.lang.NullPointerException
  42. at mindmApp.quiz.GameNormalActivity.evaluateAnswer(GameNormalActivity.java:259)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement