You see then I have the following code and I just started on this android, well I have a problem running the app on my cell phone (it says that it has closed unexpectedly), which I can not find the error because in the emulator of my laptop runs well, I have the files added, any ideas?
package mx.edu.itoaxaca.oraciones;
import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Iterator;
public class Palabras extends AppCompatActivity {
private ArrayList<Object> pistas;
private MediaPlayer reprod;
private String texto;
private TextView ora;
private boolean bandSujeto,bandAd,bandAc,bandLugar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_palabras);
reprod=null;
pistas=new ArrayList<Object>();
ora=(TextView)findViewById(R.id.oracion);
bandSujeto=false;
bandAc=false;
bandLugar=false;
bandAd=false;
texto="";
}
public void reproducir(View eve){
ora.setText("");
texto="";
switch (eve.getId()){
case R.id.dog:
pistas.add(R.raw.perro);
bandSujeto=true;
texto+="El perro ";
//play(R.raw.perro);
break;
case R.id.lion:
pistas.add(R.raw.leon);
bandSujeto=true;
texto+="El león ";
//play(R.raw.leon);
break;
case R.id.elephant:
pistas.add(R.raw.elefante);
bandSujeto=true;
texto+="El elefante ";
//play(R.raw.elefante);
break;
case R.id.parrow:
pistas.add(R.raw.guacamaya);
bandSujeto=true;
texto+="La guacamaya ";
//play(R.raw.guacamaya);
break;
}
}
public void adjetivo(View eve){
if(bandSujeto==false){
Toast to= Toast.makeText(getApplicationContext(),"Seleccione un Sujeto primero!",Toast.LENGTH_LONG);
to.show();
}else{
switch (eve.getId()){
case R.id.man:
pistas.add(R.raw.manchas);
bandAd=true;
texto+="con manchas ";
//play(R.raw.perro);
break;
case R.id.feroz:
pistas.add(R.raw.feroz);
bandAd=true;
texto+="feroz ";
//play(R.raw.perro);
break;
case R.id.afric:
pistas.add(R.raw.africano);
bandAd=true;
texto+="africano ";
//play(R.raw.perro);
break;
case R.id.ruidosa:
pistas.add(R.raw.ruidosa);
bandAd=true;
texto+="ruidosa ";
//play(R.raw.perro);
break;
}
}
}
public void accion(View eve){
if(bandAd==false){
Toast to= Toast.makeText(getApplicationContext(),"Seleccione un adjetivo primero!",Toast.LENGTH_LONG);
to.show();
}else{
switch (eve.getId()){
case R.id.eat:
pistas.add(R.raw.come);
bandAc=true;
texto+="come ";
//play(R.raw.perro);
break;
case R.id.caza:
pistas.add(R.raw.caza);
bandAc=true;
texto+="caza ";
//play(R.raw.perro);
break;
case R.id.bania:
pistas.add(R.raw.bana);
bandAc=true;
texto+="se baña ";
//play(R.raw.perro);
break;
case R.id.sing:
pistas.add(R.raw.canta);
bandAc=true;
texto+="canta ";
//play(R.raw.perro);
break;
}
}
}
public void lugar(View eve){
if(bandAc==false){
Toast to= Toast.makeText(getApplicationContext(),"Seleccione una accion primero!",Toast.LENGTH_LONG);
to.show();
}else{
switch (eve.getId()){
case R.id.house:
pistas.add(R.raw.casa);
bandAd=true;
texto+="en casa ";
//play(R.raw.perro);
break;
case R.id.origen:
pistas.add(R.raw.sabana);
bandAd=true;
texto+="en la sabana ";
//play(R.raw.perro);
break;
case R.id.lago:
pistas.add(R.raw.lago);
bandAd=true;
texto+="en el lago ";
//play(R.raw.perro);
break;
case R.id.three:
pistas.add(R.raw.arbol);
bandAd=true;
texto+="en el arbol ";
//play(R.raw.perro);
break;
}
}
}
public void play(View eve){
ora.setText(texto);
if(reprod!=null){
stopPlaying();
}
new Thread(new Runnable() {
@Override
public void run() {
Iterator<Object> it=pistas.iterator();
try {
while (it.hasNext()) {
//Thread.sleep(1000);
Object num = it.next();
reprod = MediaPlayer.create(getApplicationContext(), (int) num);
reprod.start();
Thread.sleep(1050);
}
pistas.clear();
}catch(Exception e){;}
}
}).start();
}
public void rest(View eve){
if(reprod!=null){
reprod.release();
reprod = null;}
texto="";
ora.setText("");
pistas.clear();
bandAc=false;
bandAd=false;
bandSujeto=false;
bandLugar=false;
}
private void stopPlaying() {
if (reprod != null) {
reprod.stop();
reprod.release();
reprod = null;
}
}
public void vacia(){
if(reprod.isPlaying())
pistas.clear();
}
}