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