I know that this question has been already asked, but the existing answers do not work for me.
Here is my code :
public class OrganizatorActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_organizator);
Button newText = (Button)findViewById(R.id.newText);
newText.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(OrganizatorActivity.this, NewnoteActivity.class);
OrganizatorActivity.this.StartActivity(intent);
}
});
}
}
Error : The method StartActivity(Intent) is undefined for the type OrganizatorActivity
I tried this too :
StartActivity(intent);
Error : The method StartActivity(Intent) is undefined for the type new View.OnClickListener(){}
And this doesn’t work either :
getApplicationContext().StartActivity(intent);
Error : The method StartActivity(Intent) is undefined for the type Context
My API level is 8, Android 2.2.
OrganizatorActivity is my main activity and NewnoteActivity is the activity i want to open with the intent ( called from button click ).
Thank you in advance.
StartActivity should be startActivity. Lowercase ‘s’. Also, as a hind thought, you don’t really need
OrganizatorActivity.this. This scope is implied. Just placingstartActivity(Intent)would work.