Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.86 KB | None | 0 0
  1. package com.navigationspeechclient;
  2.  
  3. import android.support.v4.app.FragmentActivity;
  4. import android.os.Bundle;
  5.  
  6.  
  7.  
  8. import com.google.android.gms.maps.CameraUpdateFactory;
  9. import com.google.android.gms.maps.GoogleMap;
  10. import com.google.android.gms.maps.OnMapReadyCallback;
  11. import com.google.android.gms.maps.SupportMapFragment;
  12. import com.google.android.gms.maps.model.LatLng;
  13. import com.google.android.gms.maps.model.MarkerOptions;
  14.  
  15.  
  16. import android.content.Context;
  17. import android.speech.tts.TextToSpeech;
  18. import android.widget.Toast;
  19.  
  20. import java.util.Locale;
  21.  
  22.  
  23.  
  24. class Callbacks {
  25.  
  26.      void callback(String jstr) {
  27.             System.out.println("Hello from c++ " + jstr);
  28.     }
  29.  
  30.  
  31. }
  32.  
  33. public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
  34.  
  35.     private GoogleMap mMap;
  36.     private TextToSpeech textToSpeech;
  37.  
  38.  
  39.     public Context sup_context;//getApplication().getApplicationContext();
  40.  
  41.     public void SpeakForMe(String astr)
  42.     {
  43.         pikok = 3;
  44.         textToSpeech.speak( astr, TextToSpeech.QUEUE_FLUSH, null, null);
  45.         //Toast.makeText(sup_context, astr, Toast.LENGTH_SHORT).show();
  46.     }
  47. int pikok;
  48.     public void HELLO_THERE()
  49.     {
  50.         SpeakForMe("TEST");
  51.         //Toast.makeText(getApplicationContext(), "KUPA", Toast.LENGTH_SHORT).show();
  52.     }
  53.  
  54.     public void InitMe() {
  55.  
  56.         textToSpeech = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
  57.             @Override
  58.             public void onInit(int status) {
  59.  
  60.                 if (status == TextToSpeech.SUCCESS) {
  61.                     int ttsLang = textToSpeech.setLanguage(Locale.US);
  62.  
  63.  
  64.                     Toast.makeText(getApplicationContext(), "INITIATED", Toast.LENGTH_SHORT).show();
  65.                     CallMainCPP();
  66. /*
  67.                   int speechStatus = textToSpeech.speak("Systems damaged", TextToSpeech.QUEUE_FLUSH, null, null);
  68.                     while (textToSpeech.isSpeaking()) {}
  69.                     speechStatus = textToSpeech.speak("Systems on line", TextToSpeech.QUEUE_FLUSH, null, null);
  70.                     while (textToSpeech.isSpeaking()) {}
  71.                     speechStatus = textToSpeech.speak("Systems online", TextToSpeech.QUEUE_FLUSH, null, null);
  72.                     while (textToSpeech.isSpeaking()) {}
  73.                     speechStatus = textToSpeech.speak("Client connected", TextToSpeech.QUEUE_FLUSH, null, null);
  74.                     while (textToSpeech.isSpeaking()) {}
  75.                     speechStatus = textToSpeech.speak("Check speed", TextToSpeech.QUEUE_FLUSH, null, null);
  76.                     while (textToSpeech.isSpeaking()) {}
  77.                     speechStatus = textToSpeech.speak("Too fast", TextToSpeech.QUEUE_FLUSH, null, null);
  78. */
  79.  
  80.  
  81.  
  82.                 } else
  83.                 {
  84.  
  85.                     Toast.makeText(getApplicationContext(), "KKCHCH", Toast.LENGTH_SHORT).show();
  86.  
  87.                 }
  88.             }
  89.  
  90.         });
  91.  
  92.  
  93.     }
  94.  
  95.     @Override
  96.     protected void onCreate(Bundle savedInstanceState) {
  97.         super.onCreate(savedInstanceState);
  98.         // startService(new Intent(this, YourService.class));
  99.         setContentView(R.layout.activity_maps);
  100.         // Obtain the SupportMapFragment and get notified when the map is ready to be used.
  101.         SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
  102.                 .findFragmentById(R.id.map);
  103.         mapFragment.getMapAsync(this);
  104.         sup_context = getApplicationContext();
  105.         InitJavaEnviromentVariablesForNativeSupport();
  106.  
  107.     }
  108.  
  109.     public static void CallMainCPP() {
  110.         new MapsActivity().main2();  // Create an instance and invoke the native method
  111.     }
  112.  
  113.     private native void main2();
  114.     private native void InitJavaEnviromentVariablesForNativeSupport();
  115.     static {
  116.         System.loadLibrary("native-lib");
  117.     }
  118.  
  119.     /**
  120.      * Manipulates the map once available.
  121.      * This callback is triggered when the map is ready to be used.
  122.      * This is where we can add markers or lines, add listeners or move the camera. In this case,
  123.      * we just add a marker near Sydney, Australia.
  124.      * If Google Play services is not installed on the device, the user will be prompted to install
  125.      * it inside the SupportMapFragment. This method will only be triggered once the user has
  126.      * installed Google Play services and returned to the app.
  127.      */
  128.     @Override
  129.     public void onMapReady(GoogleMap googleMap) {
  130.         mMap = googleMap;
  131.  
  132.         // Add a marker in Sydney and move the camera
  133.         LatLng sydney = new LatLng(-34, 151);
  134.         mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
  135.         mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
  136.   /*      qfriday = new ttsengine();
  137.         sup_context = getApplicationContext();
  138.         qfriday.InitMe(sup_context);*/
  139.         InitMe();
  140.     }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement