Force Closing on application start?

All your problems with Audio, Video and Images.

Force Closing on application start?

Postby leightonw87 » Tue May 17, 2011 8:52 am

Hi everyone, I'm a complete newbie to android programming and having a few problems, I'm trying to run a app I'm making on my Xperia x10 mini and it keeps force closing, Eclipse says there are no errors but I can't get it to start.

As soon as I got the snippet to work, I can't get it past the force close. It doesn't even start.

Main.XML
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    <AbsoluteLayout android:layout_width="fill_parent" android:id="@+id/frameLayout1" android:background="@drawable/background" android:layout_height="fill_parent">
        <ImageView android:layout_height="wrap_content" android:src="@drawable/display1" android:layout_width="wrap_content" android:id="@+id/background"></ImageView>
        <ImageButton android:src="@drawable/playbutton" android:layout_height="wrap_content" android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_x="77dip" android:layout_y="193dip"></ImageButton>
        <ImageButton android:id="@+id/imageButton3" android:src="@drawable/fastforward" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="248dip" android:layout_y="190dip"></ImageButton>
        <ImageButton android:id="@+id/imageButton2" android:src="@drawable/skipback" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="-13dip" android:layout_y="192dip"></ImageButton>
    </AbsoluteLayout>
</LinearLayout>


Sapphire.java
Code: Select all
package sapphire.com;

import android.app.Activity;
import android.os.Bundle;
import android.media.MediaPlayer;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

public class sapphire extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
   MediaPlayer mp3;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
          
         ImageButton Play = (ImageButton)findViewById(R.id.imageButton1);
         Play.setOnClickListener(this);
          
      }

      public void onClick(View v) {
         // TODO Auto-generated method stub
        
         mp3 = MediaPlayer.create(this, R.raw.soundfile_1);
         mp3.start();
         while (mp3.isPlaying()) {
            // donothing
         };
         mp3.release();
      }
   };


I've tried using a code snippet for the MediaPlayer bit, like I said I'm new to Android and never touched Java ever so I'm not very knowledgeable in this thing.
leightonw87
Once Poster
Once Poster
 
Posts: 1
Joined: Tue May 17, 2011 8:40 am

Top

Re: Force Closing on application start?

Postby wakawaka » Tue May 17, 2011 11:14 am

Please post your LogCat report here.
Android Development Tutorials and Code Snippets: http://forum.gssdaily.com/
wakawaka
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Tue Jan 11, 2011 1:51 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 27 guests