当前位置: 首页>>代码示例>>Java>>正文


Java OnInitListener类代码示例

本文整理汇总了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();
}
 
开发者ID:kupoko,项目名称:Tiresias,代码行数:26,代码来源:PointCloudActivity.java

示例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.");
           }
       }
   }
 
开发者ID:noundla,项目名称:Sunny_android_samples,代码行数:21,代码来源:TextToSpeechActivity.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:TextToSpeechICS.java

示例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);
    }
}
 
开发者ID:GigigoGreenLabs,项目名称:permissionsModule,代码行数:14,代码来源:TextToSpeechICS.java

示例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");
            }

        }
    });
}
 
开发者ID:dialogflow,项目名称:dialogflow-java-client,代码行数:15,代码来源:MainActivity.java

示例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);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:12,代码来源:AnnouncementPeriodicTaskTest.java

示例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);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:12,代码来源:AnnouncementPeriodicTaskTest.java

示例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);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:9,代码来源:AnnouncementPeriodicTaskTest.java

示例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);
			}
		});
	}
});
  }
 
开发者ID:kevalbhatt,项目名称:learn-android-examples,代码行数:23,代码来源:MainActivity.java

示例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;
}
 
开发者ID:dotcool,项目名称:coolreader,代码行数:9,代码来源:TtsHelper.java

示例11: initTTS

import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
private void initTTS(){
	OnInitListener listener = new TtsListener();
	tts = new TextToSpeech(this, listener);
	
}
 
开发者ID:liningwang,项目名称:camera,代码行数:6,代码来源:MainActivity.java

示例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);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:14,代码来源:AnnouncementPeriodicTask.java

示例13: TextToSpeechDelegate

import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
public TextToSpeechDelegate(Context context, OnInitListener listener) {
  super(context, listener);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:4,代码来源:AnnouncementPeriodicTaskTest.java

示例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);
    }
  };
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:61,代码来源:AnnouncementPeriodicTaskTest.java

示例15: setOnInitListener

import android.speech.tts.TextToSpeech.OnInitListener; //导入依赖的package包/类
public void setOnInitListener(OnInitListener onInit) {
	this.onInitListener = onInit;
}
 
开发者ID:dotcool,项目名称:coolreader,代码行数:4,代码来源:TtsService.java


注:本文中的android.speech.tts.TextToSpeech.OnInitListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。