bharath
bharath

Reputation: 147

Navigation from one screen to another screen not working in android

public class check extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }

    void myonclick(View view)
    {
        Intent mIntent = new Intent(this,check2.class);
         startActivity(mIntent);
    }
}


class check2 extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
       // super.onCreate(savedInstanceState);
       // setContentView(R.layout.main);

        Toast.makeText(
                this,
                "Welcome to second page", Toast.LENGTH_LONG).show();
        finish();  

    }
}

Hi. This is my code when I run this. When I click a button it will show error in emulator: The Application Check has stopped unexpectedly.

Upvotes: 0

Views: 815

Answers (2)

Saran
Saran

Reputation: 167

In the Manifest File declare Two Activities like

<activity android:name=".LoginForm" android:label=" Login"/>

Here FrontPage is first file name Here LoginForm is Second file name Then When FrontPage file onclick the button the event will fire

code for that

           Intent userintent = new Intent(FrontPage.this, LoginForm.class);
    startActivity(userintent);
    finish();

Upvotes: 0

Manish Khot
Manish Khot

Reputation: 3037

Have you declared both the activities in manifest file ?

The main activity should have the following intent-filter tag

<intent-filter> <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>

The second activity to be declared as

<activity android:name="check2">

Also calling finish() in the second activity would immediately return the control to the first activity.

Upvotes: 1

Related Questions