I get an error every time i click the navdown button "The application have been stopped unexpectedly Please try again". what does it mean?? im a new student in mobile developing.. please help i need to learn about this error

public class chapter1 extends Activity {
	MediaPlayer sButton;
	Intent intent;
	private Button navup;
	private Button navdown;
	private WebView view = null;
	private String url = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.chapter1);
		url = getResources().getString(R.string.c1);
		view = (WebView) findViewById(R.id.html1);
		view.loadUrl(url);
		view.setInitialScale(80);		
		navlist();
		sButton = MediaPlayer.create(this, R.raw.page3);
	}
	private void navlist() {
		navup = (Button)findViewById(R.id.prev);
		navdown = (Button)findViewById(R.id.next);
			navup.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				intent = new Intent(chapter1.this, chapters.class);
				startActivity(intent);
				sButton.start();
			}
		});					
		       navdown.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				intent = new Intent(chapter1.this, chapter2.class);
				startActivity(intent);
				sButton.start();
				
			}
		});
	}		
}

Recommended Answers

All 4 Replies

Can you post whole code? What you using as reference to write code?

Can you post whole code? What you using as reference to write code?

sir this is chapter1.java

public class chapter1 extends Activity {
	MediaPlayer sButton;
	Intent intent;
	private Button navup;
	private Button navdown;
	private WebView view = null;
	private String url = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.chapter1);
		url = getResources().getString(R.string.c1);
		view = (WebView) findViewById(R.id.html1);
		view.loadUrl(url);
		view.setInitialScale(80);		
		navlist();
		sButton = MediaPlayer.create(this, R.raw.page3);
	}

	private void navlist() {
		navup = (Button)findViewById(R.id.prev);
		navdown = (Button)findViewById(R.id.next);
		
		navup.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				intent = new Intent(chapter1.this, chapters.class);
				startActivity(intent);
				sButton.start();
			}
		});
					
		navdown.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				intent = new Intent(chapter1.this, chapter2.class);
				startActivity(intent);
				sButton.start();
				
			}
		});
	}		
}

and chapter1.java is what you see above and this is chapter2.java

public class chapter2 extends Activity {
	MediaPlayer sButton;
	Intent intent;
	private Button navup;
	private Button navdown;
	private WebView view1 = new WebView(null);
	private String url1 = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.chapter2);
		url1 = getResources().getString(R.string.c2);
		view1 = (WebView) findViewById(R.id.html2);
		view1.loadUrl(url1);
		view1.setInitialScale(80);
		navlist();
		sButton = MediaPlayer.create(this, R.raw.page3);
	}
	
	private void navlist() {
		navup = (Button)findViewById(R.id.prev);
		
		navup.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				intent = new Intent(chapter2.this, chapter1.class);
				startActivity(intent);
				sButton.start();
			}
		});
		
		navdown = (Button)findViewById(R.id.next);
		
		navdown.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				intent = new Intent(chapter2.this, chapter3.class);
				startActivity(intent);
				sButton.start();
				
			}
		});
	}

}

and this is its manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.hummingbird.mik"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="3" />

    <application android:icon="@drawable/icon">
        <activity android:name=".AndroidHummingBird" android:label="Main View">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".chapters" android:label="@string/chapters">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
		<activity android:name=".chapter1" android:label="@string/chapter1">
			<intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
		</activity>
		<activity android:name=".chapter2" android:label="@string/chapter2">
		</activity>
		<activity android:name=".chapter3" android:label="@string/chapter3">
		</activity>
		<activity android:name=".chapter4" android:label="@string/chapter4">
		</activity>
    </application>
</manifest>

and the layout xml of chapter1.java

<?xml version="1.0" encoding="utf-8"?>
<!-- This XML file defines the layout for the About view. -->
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:orientation="vertical"
  android:layout_height="fill_parent"
  android:background="#EBEFFB"
  >
  
  <FrameLayout 
  	android:layout_height="fill_parent"
  	android:layout_width="fill_parent"
  	android:layout_gravity="bottom"
  	android:id="@+id/frame01">
 
    <WebView 
  		android:layout_height="fill_parent"
  		android:layout_width="fill_parent"
  		android:id="@+id/html1"
  		android:background="@drawable/background">
  	</WebView>
  	
  	<LinearLayout 
  		android:layout_height="50dp"
  		android:layout_width="fill_parent"
  		android:background="#657383"
  		android:layout_gravity="bottom"
  		android:id="@+id/controls"
  		android:orientation="horizontal">
  		
  		<LinearLayout 
  			android:layout_height="40dp"
  			android:layout_width="fill_parent"
  			android:background="#657383"
  			android:layout_gravity="center_vertical"
  			android:id="@+id/chandler"
  			android:orientation="horizontal">
  			
  			<LinearLayout 
  				android:layout_height="wrap_content"
  				android:layout_width="wrap_content"
  				android:background="#657383"
  				android:layout_gravity="center_vertical">
  				
  			<LinearLayout 
  				android:layout_height="wrap_content"
  				android:layout_width="wrap_content"
  				android:background="#657383"
  				android:layout_gravity="center_vertical">
  				
  				<Button 
  					android:layout_height="40dp"
  					android:layout_width="160dp"
  					android:id="@+id/prev"  					
  					android:textStyle="bold"
  					android:text="^"
  					android:layout_gravity="center_horizontal"/>
  			</LinearLayout>    
  			  			
  			<LinearLayout 
  				android:layout_height="wrap_content"
  				android:layout_width="fill_parent"
  				android:background="#657383"
  				android:layout_gravity="center_vertical">
  				
  				<Button 
  					android:layout_width="160dp" 
  					android:layout_height="40dp" 
  					android:layout_gravity="center_horizontal" 
  					android:id="@+id/next"
  					android:gravity="center"
  					android:text="v">
  				</Button>
  			</LinearLayout>
  		
  		</LinearLayout>	  			
  		</LinearLayout>  		
  	</LinearLayout>
</FrameLayout>
</LinearLayout>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.