Marcos omitidos. La aplicación puede estar haciendo demasiado trabajo en su hilo principal "error en android 4.3 nexus 7

import java.io.BufferedReader; public class Main extends Activity implements SurfaceHolder.Callback, MediaPlayer.OnCompletionListener, View.OnClickListener, OnInitListener { String SrcPath = ""; MediaPlayer mp; SurfaceView mSurfaceView; private SurfaceHolder holderrrr; Boolean play = false; String t_alarm1 = "alarm.xml", t_alarm2 = "alarm2.xml", text; // TextToSpeach private TextToSpeech mText2Speech; @Override protected void onCreate(Bundle savedInstanceState) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder() .permitAll().build(); StrictMode.setThreadPolicy(policy); super.onCreate(savedInstanceState); setContentView(R.layout.main); addListenerOnButton(); mText2Speech = new TextToSpeech(Main.this, Main.this); } // menü @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_settings: { Intent myIntent = new Intent(this, menu.class); Main.this.startActivity(myIntent); return true; } } return true; } // kilépésfigyelő private static final long DOUBLE_PRESS_INTERVAL = 2000000000;// 2 másodperc private long lastPressTime; @Override public void onBackPressed() { Toast.makeText(Main.this, getString(R.string.kilepes_dupla), Toast.LENGTH_SHORT).show(); long pressTime = System.nanoTime(); if (pressTime - lastPressTime <= DOUBLE_PRESS_INTERVAL) { // this is a double click event System.exit(0); } lastPressTime = pressTime; } public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { mText2Speech.setLanguage(Locale.getDefault()); // alaértelmezett // nyelv a TtS-hez } } private void addListenerOnButton() { final Button button5 = (Button) findViewById(R.id.button5); button5.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click if (play) { try{ mp.stop(); mp.release(); mp = null; }catch(Exception e){ } button5.setText("Start"); play = false; } else { try { mp = new MediaPlayer(); mSurfaceView = (SurfaceView) findViewById(R.id.surface); holderrrr = mSurfaceView.getHolder(); play = true; button5.setText("Stop"); surfaceCreated(holderrrr); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); }// addlistener vége public void surfaceCreated(SurfaceHolder holder) { mp.setDisplay(holder); holder = mSurfaceView.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); try { mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mp.stop(); mp.release(); Toast.makeText(Main.this, "A videó lejátszás befejeződött!", Toast.LENGTH_SHORT).show(); // button5.setText("Start"); //play = false; } }); mp.setDataSource(SrcPath); mp.prepare(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Get the dimensions of the video // int videoWidth = mp.getVideoWidth(); // int videoHeight = mp.getVideoHeight(); // Get the width of the screen // int screenWidth = getWindowManager().getDefaultDisplay().getWidth(); // Get the SurfaceView layout parameters android.view.ViewGroup.LayoutParams lp = mSurfaceView.getLayoutParams(); // Set the width of the SurfaceView to the width of the screen // lp.width = screenWidth; lp.width = 420; // Set the height of the SurfaceView to match the aspect ratio of the // video // be sure to cast these as floats otherwise the calculation will likely // be 0 // lp.height = (int) (((float) videoHeight / (float) videoWidth) * // (float) screenWidth); lp.height = 390; // Commit the layout parameters mSurfaceView.setLayoutParams(lp); // Start video mp.start(); } } } 

Funciona bien en el 4.1.2 android en la galaxia s3, pero me da el mensaje de error que está en el título. Y no muestra el primer video de 3 segundos … por favor, dame algún consejo o solución de som con esto porque no tengo idea de cómo deshacerse de este tipo de error

En términos simples, este error significa que usted está pidiendo a su sistema Android que haga mucho trabajo en el hilo principal de esta aplicación en particular. Hay algunas buenas respuestas generales sobre este error, un buen ejemplo:

https://stackoverflow.com/a/21126690/334402

Para su ejemplo específico, usted puede estar pidiendo simplemente que haga demasiado trabajo relacionado video, que es muy hambriento del procesador, en el hilo principal. Vale la pena mirar su método de preparación por ejemplo y si está utilizando una fuente de streaming, considere usar prepareAsynch – vea a continuación de la documentación de Android:

Public void prepareAsync ()

Se agrega en el nivel 1 de la API Prepara el reproductor para su reproducción de forma asíncrona. Después de configurar el origen de datos y la superficie de visualización, necesita llamar a prepare () o prepareAsync (). Para los flujos, debe llamar a prepareAsync (), que devuelve inmediatamente, en lugar de bloquear hasta que se haya almacenado suficiente información.

Una de las razones por las que usted puede ver problemas en el Nexus 7 y no en el Galaxy 3 es que el Nexus tiene una pantalla significativamente más grande y su fuente de vídeo puede ofrecer diferentes codificaciones de vídeo para diferentes dispositivos de tamaño – Decodificar y renderizar.

  • Los archivos de video locales no se reproducirán en la aplicación para Android de Cordova
  • Cómo manejar la orientación del vídeo desde dispositivos móviles
  • Vídeo incrustado HTML5 de Android
  • Grabación de vídeo de Android Vine / Instagram
  • Recortar video como whatsapp
  • Resample / upsample sonidos de 8Khz a 48Khz (Java / Android)
  • Android - 360 metadatos de vídeo
  • Obtener la URL de descarga para el vídeo de YouTube (Android / Java)
  • Cómo jugar video HTML5 en línea con Phonegap para Android 4.1.1
  • ¿Cómo puedo ejecutar la línea de comandos FFMPEG y aceptar múltiples tuberías (vídeo y audio) sin bloquear en la primera entrada?
  • Reproducción de vídeo local en WebView en Android
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.