Note that there are some explanatory texts on larger screens.

plurals
  1. POThe application has stpped unexpectedly
    primarykey
    data
    text
    <p>When I start the following app in Android emulator the app stops with the following error message : "The application Player (process kilbo.net) has stpped unexpectedly. Please try again." There are no errors, warnings and I can't find anything in debugger related to the problem. This is a common problem I have, not just with this app.</p> <pre><code> package kilbo.net; import java.io.IOException; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ProgressBar; import android.widget.TextView; public class Player extends Activity implements Runnable, OnClickListener{ private TextView Status; private ProgressBar progressBar; private Button StartMedia; private Button Stop; private MediaPlayer mp; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Status = (TextView) findViewById(R.id.Status); progressBar = (ProgressBar) findViewById(R.id.progressBar); StartMedia = (Button) findViewById(R.id.StartMedia); Stop = (Button) findViewById(R.id.Stop); //Removing this two lines "fixes" the problem. So the error is probably related to this StartMedia.setOnClickListener(this); Stop.setOnClickListener(this); } @Override public void onClick(View v) { if(v.equals(StartMedia)){ if(mp != null &amp;&amp; mp.isPlaying()) return; MediaPlayer mp = new MediaPlayer(); try { mp.setDataSource("http://kilbo.net/musik/Norrskenet.mp3"); } catch (IllegalArgumentException 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(); } mp.start(); Status.setText("playingMedia"); progressBar.setVisibility(ProgressBar.VISIBLE); progressBar.setProgress(0); progressBar.setMax(mp.getDuration()); new Thread(this).start(); } if(v.equals(Stop) &amp;&amp; mp!=null){ mp.stop(); mp = null; Status.setText("Stop"); progressBar.setVisibility(ProgressBar.GONE); } } @Override public void run() { int CurrentPosition= 0; int total = mp.getDuration(); while(mp!=null &amp;&amp; CurrentPosition&lt;total){ try { Thread.sleep(1000); CurrentPosition= mp.getCurrentPosition(); } catch (InterruptedException e) { return; } catch (Exception e){ return; } progressBar.setProgress(CurrentPosition); } } } &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;Button id="@+id/Stop" android:layout_width="125px" android:layout_height="50px" android:background="#FF222222" android:text="Start" /&gt; &lt;Button id="@+id/StartMedia" android:layout_width="125px" android:layout_height="50px" android:background="#FF222222" android:text="Start" /&gt; &lt;ProgressBar id="@+id/progressBar" android:layout_width="125px" android:layout_height="50px" android:background="#FF222222" android:text="Start" style="?android:attr/progressBarStyleHorizontal" /&gt; &lt;TextView id="@+id/Status" android:layout_width="125px" android:layout_height="50px" android:background="#FF222222" android:text="Start" /&gt; &lt;/LinearLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload