I’m Trying to open a second screen for my application. The user have to click on a menu item and then the screen must open. But what i try it always just ignores the rule after the case statement.
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.OpenScreen: startActivity(new Intent(this, SecondScreenActivity.class));;
break;
}
return true;
I’ve also added the activity to AndroidManifest.xml inside the tag.
Any help will be apreciated
Solution
I had the finish() in the constructor of the new class.
For me your java code is correct and work for me that way.
However when I learned Android, when I came at the point of starting a new activity I faced the same problem as you, nothing was happening, without any error, simply not working.
In my case I forgot to add the activity in the AndroidManifest.xml file. Perhaps it is the same for you.
Your AndroidManifest file should contain somewhere something like that
this tell the system that SecondScreenActivity exitst.
In
http://developer.android.com/guide/topics/manifest/activity-element.html they say :
Hope this helps