-1

I have a problem "@Topic"

It is my code:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button one = (Button) findViewById(R.id.button3);
    one.setOnClickListener(this); // calling onClick() method
    Button two = (Button) findViewById(R.id.button4);
    two.setOnClickListener(this);
    Button three = (Button) findViewById(R.id.button5);
    three.setOnClickListener(this);
    Button four = (Button) findViewById(R.id.button1);
    four.setOnClickListener(this);
}

    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.button3:
                Intent i = new Intent(this, MainActivity.class);
                startActivity(i);
                break;

            case R.id.button4:
                Intent intent = new Intent(this, NewTwo.class);
                startActivity(intent);
                break;

            case R.id.button5:
                Intent intent_two = new Intent(this, NewThree.class);
                startActivity(intent_two);
                break;

            case R.id.button1:
                Intent intent_three = new Intent(this, NewFour.class);
                Toast.makeText(getApplicationContext(), "Praca w toku...", Toast.LENGTH_LONG).show();

                startActivity(intent_three);
                break;

            default:
                break;
        }

    }

And it is log error:

08-04 12:35:08.852 596-596/com.example.tomecki.alarmclock E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.tomecki.alarmclock, PID: 596 android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.tomecki.alarmclock/com.example.tomecki.alarmclock.NewTimer}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1777) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501) at android.app.Activity.startActivityForResult(Activity.java:3843) at android.app.Activity.startActivityForResult(Activity.java:3797) at android.app.Activity.startActivity(Activity.java:4114) at android.app.Activity.startActivity(Activity.java:4082) at com.example.tomecki.alarmclock.MainActivity.onClick(MainActivity.java:41) at android.view.View.performClick(View.java:4793) at android.view.View$PerformClick.run(View.java:19971) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5669) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Line 41 it is:

 case R.id.button4:
                Intent intent = new Intent(this, NewTimer.class);
 ---------->>>  startActivity(intent);
                break;

Please help me ;)

Yaseen Ahmad
  • 1,807
  • 5
  • 25
  • 43
tomecki
  • 1
  • 1

1 Answers1

0

It says in your log: have you declared this activity in your AndroidManifest.xml

Go to your AndroidManifest.xml and add your activities under the application tag like this:

<activity
        android:name=".NewTimer" />
babadaba
  • 814
  • 5
  • 20