@@ -79,7 +79,6 @@ public class MainActivity extends AppCompatActivity implements RecognitionListen
7979 private boolean faceProcessing = false ; // For throttling the calls
8080 private long animationDuration = 1000 ; // milliseconds
8181 private boolean faceDetected = false ; // For face check imageView anim to run once
82- private boolean outOfMainActivity = false ; // Flag to stop speech recognition on other activities
8382 private FrameLayout progressOverlay ; // Loading overlay wheel
8483
8584 /* Video Variables */
@@ -189,9 +188,9 @@ public void goToObjectDefinition(String word) {
189188 intent .putExtra ("word" , word );
190189 intent .putExtra ("inputLanguage" , getInputLanguage ());
191190 intent .putExtra ("outputLanguage" , getOutputLanguage ());
192- outOfMainActivity = true ;
193191 startActivity (intent );
194192 } else {
193+ // Infinity Loop here BUG
195194 goToProfileActivity ("yes" );
196195 Toast .makeText (getApplicationContext (), "Set your language!" , Toast .LENGTH_LONG ).show ();
197196 }
@@ -239,8 +238,7 @@ public void onError(int error) {
239238 Log .d (TAG , "Unknown error" );
240239 }
241240
242- if (!outOfMainActivity )
243- persistentSpeech ();
241+ persistentSpeech ();
244242 }
245243
246244 @ Override
@@ -572,8 +570,7 @@ protected void startRecognition() {
572570 mAudioManager .setStreamMute (AudioManager .STREAM_MUSIC , true ); // Mutes any sound of beep for listening
573571 mRecognizer .startListening (intent );
574572 } else { // If language not set then send back to profile activity
575- goToProfileActivity ("yes" );
576- Toast .makeText (getApplicationContext (), "Set your language!" , Toast .LENGTH_LONG ).show ();
573+ Toast .makeText (getApplicationContext (), "Your language is not set!" , Toast .LENGTH_LONG ).show ();
577574 }
578575 }
579576
@@ -695,12 +692,12 @@ protected int getOutputLanguage() {
695692 }
696693
697694 void goToProfileActivity (String firstTime ) { // Function that goes from the main activity to profile one
698- progressOverlay .setVisibility (View .VISIBLE );
695+ if (progressOverlay != null )
696+ progressOverlay .setVisibility (View .VISIBLE );
699697 Intent intent = new Intent (MainActivity .this , ProfileActivity .class );
700698 intent .putExtra ("lensFacing" , lensFacing );
701699 intent .putExtra ("mode" , currentMode .ordinal ());
702700 intent .putExtra ("firstTime" , firstTime );
703- outOfMainActivity = true ;
704701 stopListeningSpeech ();
705702 startActivity (intent );
706703 }
0 commit comments