-1

I want to start a new activity when i press the button, but when i press it my app crashes!

Where is the Problem?

Here is the code!

public void onClickButtonListener() {

    button_play = (Button)findViewById(R.id.play_button);
    button_play.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Intent intent = new Intent(".SecPage");
                    startActivity(intent);

                }
            }
    );


}
Agon Avdijaj
  • 225
  • 2
  • 15

3 Answers3

2

Your Intent should have two parameters. The current activity and the activity it is going to.

Intent intent = new Intent(this, SecPage.class);
startActivity(intent);
mattfred
  • 2,689
  • 1
  • 22
  • 38
1

Please consider the following issues,

Make sure you have specified your source and destination classes,

 Intent intent = new Intent(ActivityA.this, ActivityB.class);
    startActivity(intent);

Make sure you have added an activity tag in the manifest file,

<activity
            android:name=".ActivityA"
            android:theme="@style/FullscreenTheme" >
        </activity>

If you are using the Activity class in a different package add the full package name,

<activity
            android:name="com.silverlining.bionot.ActivityA"
            android:theme="@style/FullscreenTheme" >
        </activity>
Prokash Sarkar
  • 11,723
  • 1
  • 37
  • 50
0

You are probably trying to invoke a custom action with this constructor for Intent:

public Intent (String action)

Make sure you are using the full custom action string, something like com.google.app.myapp.SecPage.

According to android documentation,

public Intent (String action)

Create an intent with a given action. All other fields (data, type, class) are null. Note that the action must be in a namespace because Intents are used globally in the system -- for example the system VIEW action is android.intent.action.VIEW; an application's custom action would be something like com.google.app.myapp.CUSTOM_ACTION.

Community
  • 1
  • 1
bitbybit
  • 162
  • 1
  • 7