Olá pessoal, sou novo aqui no fórum.
Também estou com um problema “parecido”. Meu app roda perfeitamente no Emulador, porém quando instalo no Aparelho algumas coisas dão erro.
O que acontece, estou trabalhando com vários xml, consigo iniciar o app normalmente chamar algumas activity, mas algumas das vezes ocorre do app parar de funcionar, por exemplo, eu chamo uma actvity, depois chamo outra, quando vou chamar outra o app para. Já tentei muitas coisas, porém não encontrei o problema.
Vou mandar dois dos xml, e seus respectivos main, onde o erro acontece.
[/code]<?xml version="1.0" encoding="utf-8"?>
</LinearLayout>
<LinearLayout
android:id = "@+id/qc"
android:layout_width="194dp"
android:layout_height="316dp"
android:orientation="vertical"
android:layout_marginTop = "5dp"
android:layout_marginLeft = "50dp"
android:background = "@drawable/qcsilabas" >
<LinearLayout
android:id = "@+id/escolha"
android:layout_width="194dp"
android:layout_height="316dp"
android:orientation="vertical"
android:layout_marginTop = "0dp"
android:layout_marginLeft = "0dp">
<LinearLayout
android:id = "@+id/bcd"
android:layout_width = "match_parent"
android:layout_height = "40dp"
android:layout_marginTop = "0dp"
android:layout_marginLeft = "0dp"
android:layout_marginRight = "0dp"
android:orientation = "horizontal" >
<Button
android:id ="@+id/bb"
android:checked = "false"
android:onClick = "bb"
android:text = "b"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/bc"
android:checked = "false"
android:onClick = "bc"
android:text = "c"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/bd"
android:checked = "false"
android:onClick = "bd"
android:text = "d"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
</LinearLayout>
<LinearLayout
android:id = "@+id/fgj"
android:layout_width = "match_parent"
android:layout_height = "40dp"
android:layout_marginTop = "10dp"
android:layout_marginLeft = "0dp"
android:layout_marginRight = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bf"
android:checked = "false"
android:onClick = "bf"
android:text = "f"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/bg"
android:checked = "false"
android:onClick = "bg"
android:text = "g"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/bj"
android:checked = "false"
android:onClick = "bj"
android:text = "j"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
</LinearLayout>
<LinearLayout
android:id = "@+id/klm"
android:layout_width = "match_parent"
android:layout_height = "40dp"
android:layout_marginTop = "10dp"
android:layout_marginLeft = "0dp"
android:layout_marginRight = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bk"
android:checked = "false"
android:onClick = "bk"
android:text = "k"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/bl"
android:checked = "false"
android:onClick = "bl"
android:text = "l"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/bm"
android:checked = "false"
android:onClick = "bm"
android:text = "m"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
</LinearLayout>
<LinearLayout
android:id = "@+id/npr"
android:layout_width = "match_parent"
android:layout_height = "40dp"
android:layout_marginTop = "10dp"
android:layout_marginLeft = "0dp"
android:layout_marginRight = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bn"
android:checked = "false"
android:onClick = "bn"
android:text = "n"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/bp"
android:checked = "false"
android:onClick = "bp"
android:text = "p"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/br"
android:checked = "false"
android:onClick = "br"
android:text = "r"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
</LinearLayout>
<LinearLayout
android:id = "@+id/stv"
android:layout_width = "match_parent"
android:layout_height = "40dp"
android:layout_marginTop = "10dp"
android:layout_marginLeft = "0dp"
android:layout_marginRight = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bs"
android:checked = "false"
android:onClick = "bs"
android:text = "s"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/bt"
android:checked = "false"
android:onClick = "bt"
android:text = "t"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/bv"
android:checked = "false"
android:onClick = "bv"
android:text = "v"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
</LinearLayout>
<LinearLayout
android:id = "@+id/xz"
android:layout_width = "match_parent"
android:layout_height = "50dp"
android:layout_marginTop = "10dp"
android:layout_marginLeft = "0dp"
android:layout_marginRight = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bx"
android:checked = "false"
android:onClick = "bx"
android:text = "x"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
<Button
android:id="@+id/bz"
android:checked = "false"
android:onClick = "bz"
android:text = "z"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="-3dp"
android:layout_marginRight="28dp"
android:layout_marginTop="6dp" >
</Button>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id = "@+id/letrab"
android:layout_width="194dp"
android:layout_height="316dp"
android:orientation="vertical" >
<LinearLayout
android:id = "@+id/babe"
android:layout_width = "193dp"
android:layout_height = "60dp"
android:layout_marginTop = "30dp"
android:layout_marginLeft = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bba"
android:checked = "false"
android:onClick = "bba"
android:text = " "
android:background = "@drawable/bba"
android:layout_width="58dp"
android:layout_height="60dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="0dp"
android:layout_marginTop="-6dp" >
</Button>
<Button
android:id="@+id/bbe"
android:checked = "false"
android:onClick = "bbe"
android:text = " "
android:background = "@drawable/bbe"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="45dp"
android:layout_marginRight="0dp"
android:layout_marginTop="-10dp" >
</Button>
</LinearLayout>
<Button
android:id="@+id/bbi"
android:checked = "false"
android:onClick = "bbi"
android:text = " "
android:background = "@drawable/bbi"
android:layout_width="58dp"
android:layout_height="50dp"
android:layout_marginLeft="78dp"
android:layout_marginRight="28dp"
android:layout_marginTop="40dp" >
</Button>
<LinearLayout
android:id = "@+id/bobu"
android:layout_width = "193dp"
android:layout_height = "50dp"
android:layout_marginTop = "55dp"
android:layout_marginLeft = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bbo"
android:checked = "false"
android:onClick = "bbo"
android:text = " "
android:background = "@drawable/bbo"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="0dp"
android:layout_marginTop="5dp" >
</Button>
<Button
android:id="@+id/bbu"
android:checked = "false"
android:onClick = "bbu"
android:text = " "
android:background = "@drawable/bbu"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="43dp"
android:layout_marginRight="0dp"
android:layout_marginTop="3dp" >
</Button>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id = "@+id/letrac"
android:layout_width="194dp"
android:layout_height="316dp"
android:orientation="vertical" >
<LinearLayout
android:id = "@+id/cace"
android:layout_width = "193dp"
android:layout_height = "50dp"
android:layout_marginTop = "30dp"
android:layout_marginLeft = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bca"
android:checked = "false"
android:onClick = "bca"
android:text = " "
android:background = "@drawable/bca"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="0dp"
android:layout_marginTop="-7dp" >
</Button>
<Button
android:id="@+id/bce"
android:checked = "false"
android:onClick = "bce"
android:text = " "
android:background = "@drawable/bce"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="45dp"
android:layout_marginRight="0dp"
android:layout_marginTop="-10dp" >
</Button>
</LinearLayout>
<Button
android:id="@+id/bci"
android:checked = "false"
android:onClick = "bci"
android:text = " "
android:background = "@drawable/bci"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="78dp"
android:layout_marginRight="28dp"
android:layout_marginTop="40dp" >
</Button>
<LinearLayout
android:id = "@+id/cocu"
android:layout_width = "193dp"
android:layout_height = "50dp"
android:layout_marginTop = "55dp"
android:layout_marginLeft = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bco"
android:checked = "false"
android:onClick = "bco"
android:text = " "
android:background = "@drawable/bco"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="0dp"
android:layout_marginTop="5dp" >
</Button>
<Button
android:id="@+id/bcu"
android:checked = "false"
android:onClick = "bcu"
android:text = " "
android:background = "@drawable/bcu"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="43dp"
android:layout_marginRight="0dp"
android:layout_marginTop="3dp" >
</Button>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id = "@+id/letrad"
android:layout_width="194dp"
android:layout_height="316dp"
android:orientation="vertical" >
<LinearLayout
android:id = "@+id/dade"
android:layout_width = "193dp"
android:layout_height = "50dp"
android:layout_marginTop = "30dp"
android:layout_marginLeft = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bda"
android:checked = "false"
android:onClick = "bda"
android:text = " "
android:background = "@drawable/bda"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="0dp"
android:layout_marginTop="-7dp" >
</Button>
<Button
android:id="@+id/bde"
android:checked = "false"
android:onClick = "bde"
android:text = " "
android:background = "@drawable/bde"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="45dp"
android:layout_marginRight="0dp"
android:layout_marginTop="-10dp" >
</Button>
</LinearLayout>
<Button
android:id="@+id/bdi"
android:checked = "false"
android:onClick = "bdi"
android:text = " "
android:background = "@drawable/bdi"
android:layout_width="58dp"
android:layout_height="50dp"
android:layout_marginLeft="78dp"
android:layout_marginRight="28dp"
android:layout_marginTop="40dp" >
</Button>
<LinearLayout
android:id = "@+id/dodu"
android:layout_width = "193dp"
android:layout_height = "50dp"
android:layout_marginTop = "55dp"
android:layout_marginLeft = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bdo"
android:checked = "false"
android:onClick = "bdo"
android:text = " "
android:background = "@drawable/bdo"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="0dp"
android:layout_marginTop="5dp" >
</Button>
<Button
android:id="@+id/bdu"
android:checked = "false"
android:onClick = "bdu"
android:text = " "
android:background = "@drawable/bdu"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="43dp"
android:layout_marginRight="0dp"
android:layout_marginTop="3dp" >
</Button>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id = "@+id/letraf"
android:layout_width="194dp"
android:layout_height="316dp"
android:orientation="vertical" >
<LinearLayout
android:id = "@+id/fafe"
android:layout_width = "193dp"
android:layout_height = "65dp"
android:layout_marginTop = "20dp"
android:layout_marginLeft = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bfa"
android:checked = "false"
android:onClick = "bca"
android:text = " "
android:background = "@drawable/bfa"
android:layout_width="58dp"
android:layout_height="65dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="0dp"
android:layout_marginTop="-5dp" >
</Button>
<Button
android:id="@+id/bfe"
android:checked = "false"
android:onClick = "bfe"
android:text = " "
android:background = "@drawable/bfe"
android:layout_width="58dp"
android:layout_height="65dp"
android:layout_marginLeft="45dp"
android:layout_marginRight="0dp"
android:layout_marginTop="-6dp" >
</Button>
</LinearLayout>
<Button
android:id="@+id/bfi"
android:checked = "false"
android:onClick = "bfi"
android:text = " "
android:background = "@drawable/bfi"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="78dp"
android:layout_marginRight="28dp"
android:layout_marginTop="40dp" >
</Button>
<LinearLayout
android:id = "@+id/fofu"
android:layout_width = "193dp"
android:layout_height = "60dp"
android:layout_marginTop = "55dp"
android:layout_marginLeft = "0dp"
android:orientation = "horizontal" >
<Button
android:id="@+id/bfo"
android:checked = "false"
android:onClick = "bfo"
android:text = " "
android:background = "@drawable/bfo"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="0dp"
android:layout_marginTop="5dp" >
</Button>
<Button
android:id="@+id/bfu"
android:checked = "false"
android:onClick = "bfu"
android:text = " "
android:background = "@drawable/bfu"
android:layout_width="58dp"
android:layout_height="55dp"
android:layout_marginLeft="43dp"
android:layout_marginRight="0dp"
android:layout_marginTop="3dp" >
</Button>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/bvoltar"
android:checked = "false"
android:onClick = "bvoltar"
android:background = "@drawable/textvoltar"
android:layout_width="80dp"
android:layout_height="70dp"
android:layout_marginLeft="26dp"
android:layout_marginRight="0dp"
android:layout_marginTop="10dp" >
</Button>
<Button
android:id = "@+id/bcom"
android:layout_width = "28dp"
android:layout_height= "30dp"
android:layout_marginLeft = "134.5dp"
android:checked = "false"
android:onClick = "bcom"
android:background = "@drawable/comsom"
android:layout_marginRight = "28dp"
android:layout_marginTop = "-70dp">
</Button>
<Button
android:id = "@+id/bsem"
android:layout_width = "30dp"
android:layout_height= "30dp"
android:layout_marginLeft = "136dp"
android:checked = "false"
android:onClick = "bsem"
android:background = "@drawable/semsom"
android:layout_marginRight = "28dp"
android:layout_marginTop = "-70dp">
</Button>
<Button
android:id = "@+id/bcolecao"
android:layout_width = "150dp"
android:layout_height= "40dp"
android:layout_marginLeft = "75dp"
android:checked = "false"
android:onClick = "bcolecao"
android:text = "Mudar coleção"
android:layout_marginRight = "28dp"
android:layout_marginTop = "0dp">
</Button>
[/code]
[b]Agora segue o main do xml acima:[b]
[code]package com.example.lebebe;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;
public class silabas extends Activity {
Button bba, bbe, bbi, bbo, bbu, bca, bce, bci, bco, bcu, bda, bde, bdi, bdo, bdu, bfa, bfe, bfi, bfo, bfu;
Button bb, bc, bd, bf, bg, bj, bk, bl, bm, bn, bp, br, bs, bt, bv, bx, bz, bcom, bsem, bvoltar, bcolecao;
View escolha;
View letrab, letrac, letrad, letraf;
MediaPlayer voltar = null, silabas = null, qcaudio = null;
int auxmenu = 0;
Intent it;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.silabas);
bcolecao = (Button) findViewById(R.id.bcolecao);
escolha = (View) findViewById(R.id.escolha);
bcolecao.setVisibility(View.GONE);
escolha.setVisibility(View.VISIBLE);
bvoltar = (Button) findViewById(R.id.bvoltar);
bba = (Button) findViewById(R.id.bba);
bca = (Button) findViewById(R.id.bca);
bda = (Button) findViewById(R.id.bda);
bfa = (Button) findViewById(R.id.bfa);
bbe = (Button) findViewById(R.id.bbe);
bce = (Button) findViewById(R.id.bce);
bde = (Button) findViewById(R.id.bde);
bfe = (Button) findViewById(R.id.bfe);
bbi = (Button) findViewById(R.id.bbi);
bci = (Button) findViewById(R.id.bci);
bdi = (Button) findViewById(R.id.bdi);
bfi = (Button) findViewById(R.id.bfi);
bbo = (Button) findViewById(R.id.bbo);
bco = (Button) findViewById(R.id.bco);
bdo = (Button) findViewById(R.id.bdo);
bfo = (Button) findViewById(R.id.bfo);
bbu = (Button) findViewById(R.id.bbu);
bcu = (Button) findViewById(R.id.bcu);
bdu = (Button) findViewById(R.id.bdu);
bfu = (Button) findViewById(R.id.bfu);
letrab = (View) findViewById(R.id.letrab);
letrac = (View) findViewById(R.id.letrac);
letrad = (View) findViewById(R.id.letrad);
letraf = (View) findViewById(R.id.letraf);
bcom = (Button) findViewById(R.id.bcom);
bsem = (Button) findViewById(R.id.bsem);
bcom.setVisibility(View.VISIBLE);
bsem.setVisibility(View.GONE);
letrab.setVisibility(View.GONE);
letrac.setVisibility(View.GONE);
letrad.setVisibility(View.GONE);
letraf.setVisibility(View.GONE);
Toast.makeText(this, "Coleção silábica", Toast.LENGTH_LONG).show();
//Inicializa variável de controle
auxmenu = 1;
//Condição baseada na variável de controle "auxmenu", para verificar se o áudio do menu deve ser iniciado.
if(auxmenu == 1)
{
silabas = MediaPlayer.create(silabas.this, R.raw.somsilabas);
silabas.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer silabas)
{
//"Liberar espaço do sistema, e repetir a música enquanto estiver no menu.
silabas.start();
}
});
silabas.start();
}
}
public void mp()
{
qcaudio = MediaPlayer.create(silabas.this, R.raw.qcaudio);
qcaudio.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer qcaudio)
{
//"Liberar espaço do sistema.
qcaudio.stop();
qcaudio.release();
qcaudio = null;
}
});
qcaudio.start();
}
public void bb(View v)
{
escolha.setVisibility(View.GONE);
letrab.setVisibility(View.VISIBLE);
bcolecao.setVisibility(View.VISIBLE);
}
public void bc(View v)
{
escolha.setVisibility(View.GONE);
letrac.setVisibility(View.VISIBLE);
bcolecao.setVisibility(View.VISIBLE);
}
public void bd(View v)
{
escolha.setVisibility(View.GONE);
letrad.setVisibility(View.VISIBLE);
bcolecao.setVisibility(View.VISIBLE);
}
public void bf(View v)
{
escolha.setVisibility(View.GONE);
letraf.setVisibility(View.VISIBLE);
bcolecao.setVisibility(View.VISIBLE);
}
public void bcolecao(View v)
{
it = new Intent(silabas.this, silabas.class);
startActivity(it);
finish();
}
public void bg(View v)
{
it = new Intent(silabas.this, silabas2.class);
Bundle params = new Bundle();
params.putChar("msg", 'g');
it.putExtras(params);
startActivity(it);
finish();
}
public void bj(View v)
{
it = new Intent(silabas.this, silabas2.class);
Bundle params = new Bundle();
params.putChar("msg", 'j');
it.putExtras(params);
startActivity(it);
finish();
}
public void bk(View v)
{
it = new Intent(silabas.this, silabas2.class);
Bundle params = new Bundle();
params.putChar("msg", 'k');
it.putExtras(params);
startActivity(it);
finish();
}
public void bl(View v)
{
it = new Intent(silabas.this, silabas2.class);
Bundle params = new Bundle();
params.putChar("msg", 'l');
it.putExtras(params);
startActivity(it);
finish();
}
public void bm(View v)
{
it = new Intent(silabas.this, silabas3.class);
Bundle params = new Bundle();
params.putChar("msg", 'm');
it.putExtras(params);
startActivity(it);
finish();
}
public void bn(View v)
{
it = new Intent(silabas.this, silabas3.class);
Bundle params = new Bundle();
params.putChar("msg", 'n');
it.putExtras(params);
startActivity(it);
finish();
}
public void bp(View v)
{
it = new Intent(silabas.this, silabas3.class);
Bundle params = new Bundle();
params.putChar("msg", 'p');
it.putExtras(params);
startActivity(it);
finish();
}
public void br(View v)
{
it = new Intent(silabas.this, silabas3.class);
Bundle params = new Bundle();
params.putChar("msg", 'r');
it.putExtras(params);
startActivity(it);
finish();
}
public void bs(View v)
{
it = new Intent(silabas.this, silabas4.class);
Bundle params = new Bundle();
params.putChar("msg", 's');
it.putExtras(params);
startActivity(it);
finish();
}
public void bt(View v)
{
it = new Intent(silabas.this, silabas4.class);
Bundle params = new Bundle();
params.putChar("msg", 't');
it.putExtras(params);
startActivity(it);
finish();
}
public void bv(View v)
{
it = new Intent(silabas.this, silabas4.class);
Bundle params = new Bundle();
params.putChar("msg", 'v');
it.putExtras(params);
startActivity(it);
finish();
}
public void bx(View v)
{
it = new Intent(silabas.this, silabas4.class);
Bundle params = new Bundle();
params.putChar("msg", 'x');
it.putExtras(params);
startActivity(it);
finish();
}
public void bz(View v)
{
it = new Intent(silabas.this, silabas4.class);
Bundle params = new Bundle();
params.putChar("msg", 'z');
it.putExtras(params);
startActivity(it);
finish();
}
public void bcom(View v)
{
bcom.setVisibility(View.GONE);
bsem.setVisibility(View.VISIBLE);
silabas.release();
silabas = null;
auxmenu = 0;
}
public void bsem(View v)
{
bsem.setVisibility(View.GONE);
bcom.setVisibility(View.VISIBLE);
auxmenu = 1;
if(auxmenu == 1)
{
silabas = MediaPlayer.create(silabas.this, R.raw.somsilabas);
silabas.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer silabas)
{
//"Liberar espaço do sistema, e repetir a música enquanto estiver no menu.
silabas.start();
}
});
silabas.start();
}
}
public void bvoltar(View v)
{
voltar = MediaPlayer.create(silabas.this, R.raw.voltando);
voltar.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer voltar)
{
//"Liberar espaço do sistema.
voltar.stop();
voltar.release();
voltar = null;
}
});
voltar.start();
if(auxmenu == 1)
{
silabas.release();
silabas = null;
auxmenu = 0;
}
it = new Intent(silabas.this, MainActivity.class);
Bundle params = new Bundle();
params.putChar("msg", 's');
it.putExtras(params);
startActivity(it);
finish();
}
}
[/code]
[/b]Segue outro xml que também ocorre o erro:
[code]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id = "@+id/frutas"
android:layout_width = "300dp"
android:layout_height = "65dp"
android:layout_marginTop = "30dp"
android:layout_marginLeft = "50dp"
android:orientation = "vertical"
android:background = "@drawable/frutas">
</LinearLayout>
<LinearLayout
android:layout_width="194dp"
android:layout_height="316dp"
android:orientation="vertical"
android:layout_marginTop = "5dp"
android:layout_marginLeft = "50dp"
android:background = "@drawable/qcfrutas" >
<LinearLayout
android:id = "@+id/uvalaranja"
android:layout_width = "match_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:layout_marginTop = "0dp"
android:layout_marginLeft = "0dp"
android:layout_marginRight = "-100dp">
<Button
android:id="@+id/buva"
android:checked = "false"
android:onClick = "buva"
android:text = " "
android:background = "@drawable/buva"
android:layout_width="90dp"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="0dp"
android:layout_marginTop="15dp" >
</Button>
<Button
android:id="@+id/blaranja"
android:checked = "false"
android:onClick = "blaranja"
android:text = " "
android:background = "@drawable/blaranja"
android:layout_width="60dp"
android:layout_height="65dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="0dp"
android:layout_marginTop="6dp" >
</Button>
</LinearLayout>
<LinearLayout
android:id = "@+id/macabanana"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:layout_marginTop = "20dp"
android:layout_marginLeft = "0dp">
<Button
android:id="@+id/bmaca"
android:checked = "false"
android:onClick = "bmaca"
android:text = " "
android:background = "@drawable/bmaca"
android:layout_width="70dp"
android:layout_height="75dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="0dp"
android:layout_marginTop="20dp" >
</Button>
<Button
android:id="@+id/bbanana"
android:checked = "false"
android:onClick = "bbanana"
android:text = " "
android:background = "@drawable/bbanana"
android:layout_width="60dp"
android:layout_height="65dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="0dp"
android:layout_marginTop="12dp" >
</Button>
</LinearLayout>
<LinearLayout
android:id = "@+id/cajupera"
android:layout_width="match_parent"
android:layout_height="90dp"
android:orientation="horizontal"
android:layout_marginTop = "20dp"
android:layout_marginLeft = "0dp">
<Button
android:id="@+id/bcaju"
android:checked = "false"
android:onClick = "bcaju"
android:text = " "
android:background = "@drawable/bcaju"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="0dp"
android:layout_marginTop="12dp" >
</Button>
<Button
android:id="@+id/bpera"
android:checked = "false"
android:onClick = "bpera"
android:text = " "
android:background = "@drawable/bpera"
android:layout_width="60dp"
android:layout_height="65dp"
android:layout_marginLeft="42dp"
android:layout_marginRight="0dp"
android:layout_marginTop="6dp" >
</Button>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/bvoltar"
android:checked = "false"
android:onClick = "bvoltar"
android:background = "@drawable/textvoltar"
android:layout_width="80dp"
android:layout_height="70dp"
android:layout_marginLeft="26dp"
android:layout_marginRight="0dp"
android:layout_marginTop="10dp" >
</Button>
<Button
android:id = "@+id/bcom"
android:layout_width = "28dp"
android:layout_height= "30dp"
android:layout_marginLeft = "134.5dp"
android:checked = "false"
android:onClick = "bcom"
android:background = "@drawable/comsom"
android:layout_marginRight = "28dp"
android:layout_marginTop = "-70dp">
</Button>
<Button
android:id = "@+id/bsem"
android:layout_width = "30dp"
android:layout_height= "30dp"
android:layout_marginLeft = "136dp"
android:checked = "false"
android:onClick = "bsem"
android:background = "@drawable/semsom"
android:layout_marginRight = "28dp"
android:layout_marginTop = "-70dp">
</Button>
</LinearLayout>
[/code]
E seu respectivo main.
[code]package com.example.lebebe;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
public class frutas extends Activity {
Button buva, blaranja, bmaca, bbanana, bcaju, bpera, bcom, bsem, bvoltar;
MediaPlayer voltar = null, frutas = null, somaca = null, sombanana = null, sompera = null, somuva = null, somcaju = null, somlaranja = null, qcaudio = null;
int auxmenu = 0;
Intent it;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.frutas);
bvoltar = (Button) findViewById(R.id.bvoltar);
buva = (Button) findViewById(R.id.buva);
blaranja = (Button) findViewById(R.id.blaranja);
bmaca = (Button) findViewById(R.id.bmaca);
bbanana = (Button) findViewById(R.id.bbanana);
bcaju = (Button) findViewById(R.id.bcaju);
bpera = (Button) findViewById(R.id.bpera);
bcom = (Button) findViewById(R.id.bcom);
bsem = (Button) findViewById(R.id.bsem);
bcom.setVisibility(View.VISIBLE);
bsem.setVisibility(View.GONE);
//Inicializa variável de controle
auxmenu = 1;
//Condição baseada na variável de controle "auxmenu", para verificar se o áudio do menu deve ser iniciado.
if(auxmenu == 1)
{
frutas = MediaPlayer.create(frutas.this, R.raw.somfrutas);
frutas.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer frutas)
{
//"Liberar espaço do sistema, e repetir a música enquanto estiver no menu.
frutas.start();
}
});
frutas.start();
}
}
public void mp()
{
qcaudio = MediaPlayer.create(frutas.this, R.raw.qcaudio);
qcaudio.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer qcaudio)
{
//"Liberar espaço do sistema.
qcaudio.stop();
qcaudio.release();
qcaudio = null;
}
});
qcaudio.start();
}
public void buva(View v)
{
mp();
somuva = MediaPlayer.create(frutas.this, R.raw.somuva);
somuva.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer somuva)
{
//"Liberar espaço do sistema.
somuva.stop();
somuva.release();
somuva = null;
}
});
somuva.start();
}
public void bbanana(View v)
{
mp();
sombanana = MediaPlayer.create(frutas.this, R.raw.sombanana);
sombanana.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer sombanana)
{
//"Liberar espaço do sistema.
sombanana.stop();
sombanana.release();
sombanana = null;
}
});
sombanana.start();
}
public void bmaca(View v)
{
mp();
somaca = MediaPlayer.create(frutas.this, R.raw.somaca);
somaca.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer somaca)
{
//"Liberar espaço do sistema.
somaca.stop();
somaca.release();
somaca = null;
}
});
somaca.start();
}
public void blaranja(View v)
{
mp();
somlaranja = MediaPlayer.create(frutas.this, R.raw.somlaranja);
somlaranja.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer somlaranja)
{
//"Liberar espaço do sistema.
somlaranja.stop();
somlaranja.release();
somlaranja = null;
}
});
somlaranja.start();
}
public void bcaju(View v)
{
mp();
somcaju = MediaPlayer.create(frutas.this, R.raw.somcaju);
somcaju.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer somcaju)
{
//"Liberar espaço do sistema.
somcaju.stop();
somcaju.release();
somcaju = null;
}
});
somcaju.start();
}
public void bpera(View v)
{
mp();
sompera = MediaPlayer.create(frutas.this, R.raw.sompera);
sompera.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer sompera)
{
//"Liberar espaço do sistema.
sompera.stop();
sompera.release();
sompera = null;
}
});
sompera.start();
}
public void bcom(View v)
{
bcom.setVisibility(View.GONE);
bsem.setVisibility(View.VISIBLE);
frutas.release();
frutas = null;
auxmenu = 0;
}
public void bsem(View v)
{
bcom.setVisibility(View.VISIBLE);
bsem.setVisibility(View.GONE);
auxmenu = 1;
if(auxmenu == 1)
{
frutas = MediaPlayer.create(frutas.this, R.raw.somfrutas);
frutas.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer frutas)
{
//"Liberar espaço do sistema, e repetir a música enquanto estiver no menu.
frutas.start();
}
});
frutas.start();
}
}
public void bvoltar(View v)
{
voltar = MediaPlayer.create(frutas.this, R.raw.voltando);
voltar.setOnCompletionListener(new MediaPlayer.OnCompletionListener()//Função para não sobrecarregar a variável de reprodução
{
public void onCompletion(MediaPlayer voltar)
{
//"Liberar espaço do sistema.
voltar.stop();
voltar.release();
voltar = null;
}
});
voltar.start();
if(auxmenu == 1)
{
frutas.release();
frutas = null;
auxmenu = 0;
}
it = new Intent(frutas.this, MainActivity.class);
Bundle params = new Bundle();
params.putChar("msg", 's');
it.putExtras(params);
startActivity(it);
finish();
}
}
[/code]
Não liguem para algumas bagunças do código, ainda estou otimizando algumas coisas, porém o que não entendo é que para os outros fiz exatamente a mesma coisa, com suas devidas colocações, lógico, mas o erro acontece somente aqui.
Me ajudem, obrigado desde já.