Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.navigationspeechclient;
- import android.support.v4.app.FragmentActivity;
- import android.os.Bundle;
- import com.google.android.gms.maps.CameraUpdateFactory;
- import com.google.android.gms.maps.GoogleMap;
- import com.google.android.gms.maps.OnMapReadyCallback;
- import com.google.android.gms.maps.SupportMapFragment;
- import com.google.android.gms.maps.model.LatLng;
- import com.google.android.gms.maps.model.MarkerOptions;
- import android.content.Context;
- import android.speech.tts.TextToSpeech;
- import android.widget.Toast;
- import java.util.Locale;
- class Callbacks {
- void callback(String jstr) {
- System.out.println("Hello from c++ " + jstr);
- }
- }
- public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
- private GoogleMap mMap;
- private TextToSpeech textToSpeech;
- public Context sup_context;//getApplication().getApplicationContext();
- public void SpeakForMe(String astr)
- {
- pikok = 3;
- textToSpeech.speak( astr, TextToSpeech.QUEUE_FLUSH, null, null);
- //Toast.makeText(sup_context, astr, Toast.LENGTH_SHORT).show();
- }
- int pikok;
- public void HELLO_THERE()
- {
- SpeakForMe("TEST");
- //Toast.makeText(getApplicationContext(), "KUPA", Toast.LENGTH_SHORT).show();
- }
- public void InitMe() {
- textToSpeech = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
- @Override
- public void onInit(int status) {
- if (status == TextToSpeech.SUCCESS) {
- int ttsLang = textToSpeech.setLanguage(Locale.US);
- Toast.makeText(getApplicationContext(), "INITIATED", Toast.LENGTH_SHORT).show();
- CallMainCPP();
- /*
- int speechStatus = textToSpeech.speak("Systems damaged", TextToSpeech.QUEUE_FLUSH, null, null);
- while (textToSpeech.isSpeaking()) {}
- speechStatus = textToSpeech.speak("Systems on line", TextToSpeech.QUEUE_FLUSH, null, null);
- while (textToSpeech.isSpeaking()) {}
- speechStatus = textToSpeech.speak("Systems online", TextToSpeech.QUEUE_FLUSH, null, null);
- while (textToSpeech.isSpeaking()) {}
- speechStatus = textToSpeech.speak("Client connected", TextToSpeech.QUEUE_FLUSH, null, null);
- while (textToSpeech.isSpeaking()) {}
- speechStatus = textToSpeech.speak("Check speed", TextToSpeech.QUEUE_FLUSH, null, null);
- while (textToSpeech.isSpeaking()) {}
- speechStatus = textToSpeech.speak("Too fast", TextToSpeech.QUEUE_FLUSH, null, null);
- */
- } else
- {
- Toast.makeText(getApplicationContext(), "KKCHCH", Toast.LENGTH_SHORT).show();
- }
- }
- });
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // startService(new Intent(this, YourService.class));
- setContentView(R.layout.activity_maps);
- // Obtain the SupportMapFragment and get notified when the map is ready to be used.
- SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
- .findFragmentById(R.id.map);
- mapFragment.getMapAsync(this);
- sup_context = getApplicationContext();
- InitJavaEnviromentVariablesForNativeSupport();
- }
- public static void CallMainCPP() {
- new MapsActivity().main2(); // Create an instance and invoke the native method
- }
- private native void main2();
- private native void InitJavaEnviromentVariablesForNativeSupport();
- static {
- System.loadLibrary("native-lib");
- }
- /**
- * Manipulates the map once available.
- * This callback is triggered when the map is ready to be used.
- * This is where we can add markers or lines, add listeners or move the camera. In this case,
- * we just add a marker near Sydney, Australia.
- * If Google Play services is not installed on the device, the user will be prompted to install
- * it inside the SupportMapFragment. This method will only be triggered once the user has
- * installed Google Play services and returned to the app.
- */
- @Override
- public void onMapReady(GoogleMap googleMap) {
- mMap = googleMap;
- // Add a marker in Sydney and move the camera
- LatLng sydney = new LatLng(-34, 151);
- mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
- mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
- /* qfriday = new ttsengine();
- sup_context = getApplicationContext();
- qfriday.InitMe(sup_context);*/
- InitMe();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement