java - How to use Android TextToSpeech in CodenameOne? -


I would like to include text-to-speech functionality in my Codenam One Android app, but I do not think it's working As the codenamed one does not provide this capability in its API, I am trying to create an original interface to handle Google Maps cn1lib as an example.

Even I have so far:

NativeTTS.java

  public class Expands NativeTTS NativeInterface {Public Entry Script String (string hello); }   

NativeTTSImpl.java

  public class NativeTTSImpl apply OnInitListener, LifecycleListener, IntentResultListener {Private TextToSpeech tts; Public Zero Starter () {AndroidNativeUtil.addLifecycleListener (this); } Public Zero removal () {AndroidNativeUtil.removeLifecycleListener (this); } Public Entry Script String (String Text) {Return TTSAP (Text, TextAutoPitch. UEUUFOOSHH, blank); } Intake on public Zero {if (status == TextToSpeech.SUCCESS} {tts.SsetLanguage (Locale.US); }} Public Boolean supported () {back true; } Public Zero (intit codecode, int resultcode, intent data) on activative result {if (resultcode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) TTS = New TextTouch (AndroidNitableUtil.getActivity (), this); Other {intent installIntent = new intent (); InstallIntent.setAction (TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); AndroidNativeUtil.getActivity () .startActivity (installIntent); }} Create a public null (bundle savedinstenstate) {intent = new intent (); Intent.setAction (TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); AndroidNativeUtil.startActivityForResult (intent, this); } Destiny on Public Zero () {if (tts! = Null) {tts.stop (); Tts.shutdown (); }} Public void onResume () {} public departing pauses () {} Lomomority on Public Zero () {} Public Void Savings InstantState (Bundle B) {}}   

I use Trying to do this comes back to my app on: NetVTTS TTS = (NetVetts) Native Lookup.Sent (NativeTVs class); If (TTS! = Null & amp; amp;; TTS is supported ()) {int success = tts.speakString ("Hello World"); }

However, when I call tts.speakString (...) then I'm getting NullPointerException . I think the problem is that NativeTTSImpl.initialize () is never called, and how do I know how to call me.

You really need to get started.

The lifecycle will not only be registered by you but will work for lifecycle incidents, if you want more lifecycle incidents, then you can register any activity through the manifest but believe me Not that you need all these complications

I do not think why something does not do this:

  if (tts == null) {tts = new TextToSpeech (AndroidNativeUtil.getActivity ()), this); }    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -