本文整理汇总了Java中android.speech.tts.TextToSpeech.OnInitListener类的典型用法代码示例。如果您正苦于以下问题:Java OnInitListener类的具体用法?Java OnInitListener怎么用?Java OnInitListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OnInitListener类属于android.speech.tts.TextToSpeech包,在下文中一共展示了OnInitListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_jpoint_cloud);
setTitle(R.string.app_name);
tts=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status != TextToSpeech.ERROR) {
tts.setLanguage(Locale.UK);
}
}
});
mTango = new Tango(this);
mConfig = setupTangoConfig(mTango);
setupTextViewsAndButtons(mConfig);
int maxDepthPoints = mConfig.getInt("max_point_cloud_elements");
mPointCloudManager = new PointCloudManager(maxDepthPoints);
mRenderer = setupGLViewAndRenderer(mPointCloudManager);
mTangoUx = setupTangoUxAndLayout();
mIsTangoServiceConnected = false;
startUIThread();
}
示例2: onActivityResult
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQ_TTS_STATUS_CHECK) {
switch (resultCode) {
case TextToSpeech.Engine.CHECK_VOICE_DATA_PASS:
mTts = new TextToSpeech(this, (OnInitListener) this);
break;
case TextToSpeech.Engine.CHECK_VOICE_DATA_BAD_DATA:
case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_DATA:
case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_VOLUME:
Intent installIntent = new Intent();
installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
break;
case TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL:
default:
Log.e(TAG, "Got a failure.");
}
}
}
示例3: construct
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
static TextToSpeech construct(Context context, OnInitListener onInitListener, String engineName) {
if (VERSION.SDK_INT >= 14) {
return new TextToSpeech(context, onInitListener, engineName);
}
if (engineName == null) {
return new TextToSpeech(context, onInitListener);
}
Log.w(TAG, "Can't specify tts engine on this device");
return new TextToSpeech(context, onInitListener);
}
示例4: construct
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
static TextToSpeech construct(Context context, OnInitListener onInitListener,
String engineName) {
if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
if (engineName == null) {
return new TextToSpeech(context, onInitListener);
} else {
Log.w(TAG, "Can't specify tts engine on this device");
return new TextToSpeech(context, onInitListener);
}
} else {
return new TextToSpeech(context, onInitListener, engineName);
}
}
示例5: initTTS
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
private void initTTS() {
ttsEngine = new TextToSpeech(this, new OnInitListener() {
@Override
public void onInit(int initStatus) {
if (initStatus == TextToSpeech.SUCCESS) {
ttsEngine.setLanguage(Locale.US);
ttsReady = true;
} else {
Log.d(TAG, "Can't initialize TextToSpeech");
}
}
});
}
示例6: testStart
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
public void testStart() {
doStart();
OnInitListener ttsInitListener = initListenerCapture.getValue();
assertNotNull(ttsInitListener);
AndroidMock.replay(tts);
ttsInitListener.onInit(TextToSpeech.SUCCESS);
AndroidMock.verify(mockTask, tts);
}
示例7: testStart_notReady
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
public void testStart_notReady() {
doStart();
OnInitListener ttsInitListener = initListenerCapture.getValue();
assertNotNull(ttsInitListener);
AndroidMock.replay(tts);
ttsInitListener.onInit(TextToSpeech.ERROR);
AndroidMock.verify(mockTask, tts);
}
示例8: startTask
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
private void startTask(int state) {
AndroidMock.resetToNice(tts);
AndroidMock.replay(tts);
doStart();
OnInitListener ttsInitListener = initListenerCapture.getValue();
ttsInitListener.onInit(state);
AndroidMock.resetToDefault(tts);
}
示例9: onCreate
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
speak=(Button) findViewById(R.id.button1);
text=(EditText) findViewById(R.id.editText1);
speak.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
speaker=new TextToSpeech(getApplicationContext(), new OnInitListener() {
public void onInit(int arg0) {
// TODO Auto-generated method stub
speaker.setLanguage(Locale.ENGLISH);
speaker.speak(text.getText().toString(), TextToSpeech.QUEUE_FLUSH, null);
}
});
}
});
}
示例10: TtsHelper
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
public TtsHelper(Context context, OnInitListener listener, OnCompleteListener onComplete) {
tts = new TextToSpeech(context, this);
this.listener = listener;
this.onCompleteListener = onComplete;
queue = new ArrayList<SpeakValue>();
currentQueueIndex = 0;
}
示例11: initTTS
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
private void initTTS(){
OnInitListener listener = new TtsListener();
tts = new TextToSpeech(this, listener);
}
示例12: start
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
@Override
public void start() {
if (tts == null) {
tts = newTextToSpeech(context, new OnInitListener() {
@Override
public void onInit(int status) {
initStatus = status;
}
});
}
speechAllowed = true;
listenToPhoneState(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
示例13: TextToSpeechDelegate
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
public TextToSpeechDelegate(Context context, OnInitListener listener) {
super(context, listener);
}
示例14: setUp
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
@UsesMocks({
AnnouncementPeriodicTask.class,
StringUtils.class,
})
@Override
protected void setUp() throws Exception {
super.setUp();
oldDefaultLocale = Locale.getDefault();
Locale.setDefault(DEFAULT_LOCALE);
// Eww, the effort required just to mock TextToSpeech is insane
final AtomicBoolean listenerCalled = new AtomicBoolean();
OnInitListener blockingListener = new OnInitListener() {
@Override
public void onInit(int status) {
synchronized (this) {
listenerCalled.set(true);
notify();
}
}
};
ttsDelegate = new TextToSpeechDelegate(getContext(), blockingListener);
// Wait for all async operations done in the constructor to finish.
synchronized (blockingListener) {
while (!listenerCalled.get()) {
// Releases the synchronized lock until we're woken up.
blockingListener.wait();
}
}
// Phew, done, now we can start forwarding calls
tts = AndroidMock.createMock(TextToSpeechInterface.class);
initListenerCapture = new Capture<OnInitListener>();
phoneListenerCapture = new Capture<PhoneStateListener>();
// Create a partial forwarding mock
mockTask = AndroidMock.createMock(AnnouncementPeriodicTask.class, getContext());
task = new AnnouncementPeriodicTask(getContext()) {
@Override
protected TextToSpeech newTextToSpeech(Context ctx,
OnInitListener onInitListener) {
return mockTask.newTextToSpeech(ctx, onInitListener);
}
@Override
protected String getAnnouncement(TripStatistics stats) {
return mockTask.getAnnouncement(stats);
}
@Override
protected void listenToPhoneState(
PhoneStateListener listener, int events) {
mockTask.listenToPhoneState(listener, events);
}
};
}
示例15: setOnInitListener
import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
public void setOnInitListener(OnInitListener onInit) {
this.onInitListener = onInit;
}