Reputation: 696
I wrote a simple app involving two activities. I used an explicit intent to call the second activity, but it always force closes the app when I try to do so. Code of 1st activity
public class Splash extends Activity implements OnClickListener {
private ImageButton ibLogo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
ibLogo = (ImageButton) findViewById(R.id.imageButton1);
ibLogo.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
startActivity(new Intent(Splash.this, Menu.class));
}
}
Menu is in the same package as Splash
Android Manifest:
<activity
android:name="com.rakeshsarangi.petrofiesta2013.Menu"
android:label="@string/title_activity_menu" >
</activity>
I have seen other threads like this but none could help me. Really baffled at this simple thing.
Upvotes: 1
Views: 256
Reputation: 11324
if you are extending Menu then this might be help full
as per commons-ware answer
You are trying to start an activity named android.view.Menu. You do not have an activity named android.view.Menu.
Intent myIntent = new Intent(getApplicationContext(), Menu.class);
If you change the second parameter of the Intent constructor to the Class object for your activity, that will likely work better. Even better would be to not have an activity named Menu, but to use something more distinctive, to help prevent this sort of collision in the future.
ActivityNotFoundException on launching class that is in manifest
Upvotes: 0
Reputation: 3476
Change -
startActivity(new Intent(Splash.this, Menu.class));
to -
startActivity(new Intent(Splash.this, com.rakeshsarangi.petrofiesta2013.Menu.class));
I thin it is taking Menu
class from android.view
Upvotes: 1
Reputation: 43023
It probably thinks that the menu from the line startActivity(new Intent(Splash.this, Menu.class));
is android.view.Menu
. You should change the line to use the full name com.rakeshsarangi.petrofiesta2013.Menu
.
Upvotes: 4