/accessibilityPreferences/src/com/marvin/preferences/ResetTalkBackActivity.java

http://eyes-free.googlecode.com/ · Java · 46 lines · 34 code · 6 blank · 6 comment · 5 complexity · 6b0228ab94eff2c5f925424f82265e02 MD5 · raw file

  1. // Copyright 2011 Google Inc. All Rights Reserved.
  2. package com.marvin.preferences;
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.speech.tts.TextToSpeech;
  7. /**
  8. * This is a simple activity that, when launched, broadcasts a command to reset TalkBack
  9. *
  10. * @author credo@google.com (Tim Credo)
  11. */
  12. public class ResetTalkBackActivity extends Activity {
  13. public static final String ACTION_RESET_TALKBACK_COMMAND = "com.google.android.marvin.talkback.ACTION_RESET_TALKBACK_COMMAND";
  14. TextToSpeech mTts;
  15. @Override
  16. protected void onCreate(Bundle savedInstanceState) {
  17. super.onCreate(savedInstanceState);
  18. Intent intent = new Intent(ACTION_RESET_TALKBACK_COMMAND);
  19. sendBroadcast(intent);
  20. mTts = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
  21. @Override
  22. public void onInit(int status) {
  23. if (status == TextToSpeech.SUCCESS) {
  24. if (mTts != null) {
  25. mTts.speak("TalkBack reset", TextToSpeech.QUEUE_FLUSH, null);
  26. while (mTts.isSpeaking()) {
  27. try {
  28. Thread.sleep(100);
  29. } catch (InterruptedException e) {
  30. e.printStackTrace();
  31. }
  32. }
  33. mTts.shutdown();
  34. }
  35. }
  36. finish();
  37. }
  38. });
  39. }
  40. }