My current project involves developing an android app that includes launching a second activity
from a button click in the main activity
. However, I'm encountering the following error:
Error Cannot Find Symbol Method startActivity(Intent)
I've hit a roadblock and struggling to resolve this issue.
Below is the excerpt from my PrimaryActivity.Java
file which serves as the main activity:
package com.nickdgreen.beta;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.content.Intent;
import android.widget.Button;
public class PrimaryActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_primary);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_primary, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
Button switchButton = (Button) findViewById(R.id.button1);
switchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(PrimaryActivity.this, SecondaryActivity.class);
startActivty(intent);
}
});
}
}