I'm trying implement this method and i get this mistake:
FATAL EXCEPTION: main
android.content.ActivityNotFoundException: Unable to find explicit activity class {app.gestionservicios/android.view.Menu}; have you declared this activity in your AndroidManifest.xml?
This is my code:
Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK))
{
Intent passIntent = new Intent();
passIntent.setClass(Listado.this,Menu.class);
startActivity(passIntent);
return true;
}
return super.onKeyDown(keyCode, event);
}
And this mi manifiest.xml:
<activity
android:name=".Menu"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I don't know where is this mistake can appear, because in my manifiest.xml is declared the activity menu, and i have the java file Menu. It doesn't show compilation mistake, only execution mistake
Thanks
Make sure that in this code
Intent passIntent = new Intent();
passIntent.setClass(Listado.this,Menu.class);
Menu is your activity, not android.view.Menu class.
Or you can try next code:
Intent passIntent = new Intent();
passIntent.setClass(Listado.this, your_pacakge_name.Menu.class);
where your_pacakge_name - is the name of the package where your Menu activity is declared.