MyPlayActivity.java 1.36 KB
package tonio.noa;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Toast;


/**
 * Created by psyk on 09/01/18.
 */

public abstract class MyPlayActivity extends Activity {

    public static final int REQUEST_CODE = 1;
    protected TextToSpeech tts;

    protected abstract void next();

    protected void bravoPage(View view) {
        startActivityForResult(new Intent(this, BravoActivity.class), REQUEST_CODE);
    }

    protected void lanceConsigne(String cons) {
        Intent i = new Intent(this, ConsigneActivity.class);
        i.putExtra("keyConsigne", cons);
        int requestCode = 0;
        startActivityForResult(i, requestCode);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        try {
            super.onActivityResult(requestCode, resultCode, data);

            if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
                this.next();
                finish();
            }
        } catch (Exception ex) {
            Toast.makeText(MyPlayActivity.this, ex.toString(),
                    Toast.LENGTH_SHORT).show();
        }
    }

    public void backHome(View view) {

        startActivity(new Intent(this, MainActivity.class));
        finish();
    }

}