Ver Mensaje Individual
  #16 (permalink)  
Antiguo 11/08/2014, 16:46
marcosscalator
 
Fecha de Ingreso: mayo-2014
Mensajes: 28
Antigüedad: 10 años
Puntos: 0
Respuesta: emulador se para cuando pongo imágenes

lo voy a poner de esta forma también, pero no creo que se vea mejor, a gustos:

xml:
Código Java:
Ver original
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.     android:layout_width="wrap_content"
  5.     android:layout_height="wrap_content"
  6.     android:orientation="vertical"
  7.     android:gravity="right"
  8.     android:background="@drawable/tonto"
  9.     >
  10.  
  11.     <Button
  12.         android:id="@+id/ok"
  13.         android:layout_width="180dp"
  14.         android:layout_height="40dp"
  15.         android:layout_marginTop="310dp"
  16.         android:layout_gravity="right"
  17.         android:background="@drawable/boton_play_pulsacion"
  18.         />
  19.  
  20.     <Button
  21.         android:id="@+id/compartir"
  22.         android:layout_width="180dp"
  23.         android:layout_height="40dp"
  24.         android:layout_marginTop="10dp"
  25.         android:layout_gravity="right"
  26.         android:background="@drawable/boton_compartir_pulsacion"
  27.         />
  28.  
  29.    
  30. </LinearLayout>


java:

Código Java:
Ver original
  1. package com.pobe.freethefool;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.media.AudioManager;
  6. import android.media.MediaPlayer;
  7. import android.media.MediaPlayer.OnCompletionListener;
  8. import android.media.SoundPool;
  9. import android.os.Bundle;
  10. import android.view.View;
  11. import android.view.Window;
  12. import android.view.WindowManager;
  13. import android.view.View.OnClickListener;
  14. import android.widget.Button;
  15.  
  16.  
  17. public class SegundaPantalla<string> extends Activity implements OnClickListener, OnCompletionListener{
  18.  
  19.     private Button ok, compartir;
  20.     MediaPlayer mp1;
  21.     SoundPool sp2;
  22.     SoundPool sp3;
  23.     int share;
  24.     int again;
  25.    
  26.     @Override
  27.     protected void onCreate(Bundle savedInstanceState) {
  28.         // TODO Auto-generated method stub
  29.         super.onCreate(savedInstanceState);
  30.    
  31.         //esto quita el título de la activity en la parte superior
  32.          requestWindowFeature(Window.FEATURE_NO_TITLE);
  33.          //y esto para pantalla completa (oculta incluso la barra de estado)
  34.          this.getWindow().setFlags(
  35.          
  36.         WindowManager.LayoutParams.FLAG_FULLSCREEN,
  37.         WindowManager.LayoutParams.FLAG_FULLSCREEN);
  38.        
  39.         setContentView(R.layout.segunda_pantalla);
  40.        
  41.         this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
  42.        
  43.         ok = (Button) findViewById(R.id.ok);
  44.         ok.setOnClickListener(this);
  45.         compartir = (Button) findViewById(R.id.compartir);
  46.         compartir.setOnClickListener(this);
  47.        
  48.         sp2 = new SoundPool(3, AudioManager.STREAM_MUSIC, 0);  
  49.         share = sp2.load (this, R.raw.eswich, 1);
  50.         sp3 = new SoundPool(3, AudioManager.STREAM_MUSIC, 0);
  51.         again = sp3.load (this, R.raw.eswich, 1);  
  52.        
  53.     }
  54.  
  55.     @Override
  56.     public void onClick(View v) {
  57.         // TODO Auto-generated method stub
  58.         switch (v.getId()) {
  59.         case R.id.ok:
  60.             Intent vueltaPrimeraPantalla2 = new Intent (SegundaPantalla.this, PantallaDePulsar.class);
  61.             startActivity (vueltaPrimeraPantalla2);
  62.             if (again != 0) {
  63.             sp3.play(again, 1, 1, 0, 0, 1);
  64.             }
  65.             mp1.stop();
  66.             break;
  67.            
  68.         case R.id.compartir:
  69.             Intent i = new Intent (Intent.ACTION_SEND);
  70.             i.setType("text/plain");
  71.             i.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.texto_compartir));
  72.             startActivity (Intent.createChooser(i, getResources().getString(R.string.selector)));
  73.             if (share != 0) {
  74.             sp2.play(share, 1, 1, 0, 0, 1);
  75.             }
  76.             mp1.stop();
  77.             break;
  78.  
  79.         }
  80.     }
  81.    
  82.    
  83.     //esto sirve para señalar que la música debe parar cuando se salga de la activity o app
  84.         @Override
  85.         public void onCompletion(MediaPlayer mp) {
  86.             // TODO Auto-generated method stub
  87.            
  88.             mp1.start();
  89.            
  90.         }
  91.        
  92.         public void onStart () {
  93.             super.onStart();
  94.             mp1 = MediaPlayer.create(this, R.raw.buider);
  95.             mp1.setOnCompletionListener(this);
  96.             mp1.start();
  97.             mp1.setLooping(true);
  98.            
  99.         }
  100.        
  101.         public void onStop () {
  102.             super.onStop();
  103.             mp1.stop();
  104.             mp1.release();
  105.            
  106.         }
  107.    
  108.    
  109.     //esto hace que el botón de atrás del móvil te lleve a la primera pantalla
  110.     public void onBackPressed() {
  111.         // do something on back.
  112.         Intent vueltaPrimeraPantalla3 = new Intent (SegundaPantalla.this, PantallaDePulsar.class);
  113.         startActivity (vueltaPrimeraPantalla3);
  114.         mp1.stop();
  115.         return;
  116.         }
  117.  
  118.  
  119. }

ah pues sí, se ve mejor, pensaba que se vería como en un cajón en pequeño ;)