Hallo Leute,
ich möchte eine Extension für Android schreiben.
Folgendes Extension-Beispiel: help.yoyogames.com/hc/en-us/ar…ion-For-Android-GMS-v1-3-
funktioniert gut.
Ich habe mir auch schon andere Beispiel angeschaut.
Wie muss man Google-API-Aufrufe richtig für GM programmieren.
Kann es sein das man am besten Services, bzw. Intent's nutzen sollte.
Ich versuche die Google Tts anzusprechen.
So funktioniert das z.B nicht:
Alles anzeigen
und so auch nicht:
Alles anzeigen
Mit Intent's komme ich jetzt nicht weiter:
Alles anzeigen
Ich bekomme das hier nicht so ganz hin:
android-developers.googleblog.…to-text-to-speech-in.html
Kennt sich da jemand aus?
ich möchte eine Extension für Android schreiben.
Folgendes Extension-Beispiel: help.yoyogames.com/hc/en-us/ar…ion-For-Android-GMS-v1-3-
funktioniert gut.
Ich habe mir auch schon andere Beispiel angeschaut.
Wie muss man Google-API-Aufrufe richtig für GM programmieren.
Kann es sein das man am besten Services, bzw. Intent's nutzen sollte.
Ich versuche die Google Tts anzusprechen.
So funktioniert das z.B nicht:
Java-Quellcode
-
- package ${YYAndroidPackageName};
- import android.util.Log;
- import android.app.Activity;
- import android.os.Bundle;
- import android.speech.tts.TextToSpeech;
- import android.speech.tts.TextToSpeech.OnInitListener;
- import java.io.File;
- import java.io.FileReader;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.lang.String;
- import ${YYAndroidPackageName}.R;
- import com.yoyogames.runner.RunnerJNILib;
- public class andro_tts
- {
- TextToSpeech tts;
- public andro_tts()
- {
- tts=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
- @Override
- public void onInit(int status) {
- if(status != TextToSpeech.ERROR) {
- tts.setLanguage(Locale.GERMAN);
- }
- }
- });
- }
- public double add_number(double arg0, double arg1)
- {
- double value = arg0 + arg1;
- Log.i("yoyo", arg0 + "+" + arg1 + " = " + value);
- return value;
- }
- public String build_string(String arg0, String arg1)
- {
- String myString = arg0 + " " + arg1;
- Log.i("yoyo", myString);
- return myString;
- }
- public double tts_speak(String arg0)
- {
- tts.speak(arg0, TextToSpeech.QUEUE_FLUSH, null);
- return 0;
- }
- }
und so auch nicht:
Java-Quellcode
-
- package ${YYAndroidPackageName};
- import android.util.Log;
- import android.app.Activity;
- import android.os.Bundle;
- import android.speech.tts.TextToSpeech;
- import android.speech.tts.TextToSpeech.OnInitListener;
- import java.io.File;
- import java.io.FileReader;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.lang.String;
- import ${YYAndroidPackageName}.R;
- import com.yoyogames.runner.RunnerJNILib;
- public class andro_tts implements OnInitListener
- {
- private TextToSpeech tts;
- public andro_tts()
- {
- tts = new TextToSpeech(this, this);
- }
- public double add_number(double arg0, double arg1)
- {
- double value = arg0 + arg1;
- Log.i("yoyo", arg0 + "+" + arg1 + " = " + value);
- return value;
- }
- public String build_string(String arg0, String arg1)
- {
- String myString = arg0 + " " + arg1;
- Log.i("yoyo", myString);
- return myString;
- }
- @Override
- public void onInit(int arg0)
- {
- tts.setLanguage(Locale.GERMAN);
- }
- public double tts_speak(String arg0)
- {
- tts.speak(arg0, TextToSpeech.QUEUE_FLUSH, null);
- return 0;
- }
- }
Mit Intent's komme ich jetzt nicht weiter:
Java-Quellcode
-
- package ${YYAndroidPackageName};
- import android.util.Log;
- import android.app.Activity;
- import android.os.Bundle;
- import android.speech.tts.TextToSpeech;
- import android.speech.tts.TextToSpeech.OnInitListener;
- import java.io.File;
- import java.io.FileReader;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.lang.String;
- import ${YYAndroidPackageName}.R;
- import com.yoyogames.runner.RunnerJNILib;
- public class andro_tts implements OnInitListener {
- private TextToSpeech mTts;
- public double tts_speak(String txt)
- {
- Intent checkIntent = new Intent();
- checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
- startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
- mTts.speak(txt, TextToSpeech.QUEUE_FLUSH, null);
- return 0;
- }
- protected void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- if (requestCode == MY_DATA_CHECK_CODE) {
- if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
- mTts = new TextToSpeech(this, this);
- } else {
- Intent installIntent = new Intent();
- installIntent.setAction(
- TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
- startActivity(installIntent);
- }
- }
- }
- }
Ich bekomme das hier nicht so ganz hin:
android-developers.googleblog.…to-text-to-speech-in.html
Kennt sich da jemand aus?