Intent android

Fermé
Dalinho Messages postés 28 Date d'inscription dimanche 27 février 2011 Statut Membre Dernière intervention 6 décembre 2013 - 30 déc. 2012 à 13:18
scinarf Messages postés 1098 Date d'inscription samedi 18 novembre 2006 Statut Membre Dernière intervention 25 septembre 2014 - 6 févr. 2013 à 14:52
salut,au fait j'ai un problem avec les intents dans les menu en android

public boolean onMenuItemSelected(int featureId, MenuItem item) {

switch(item.getItemId()){
case R.id.nouveau:
Intent nouveau =new Intent(MainActivity.this,Nouveau.class);
startActivity(nouveau);
case R.id.liste:
Intent liste =new Intent(MainActivity.this,Liste.class);
startActivity(liste);
case R.id.recherche:
Intent recherche =new Intent(MainActivity.this,Recherche.class);
startActivity(recherche);
case R.id.quitter:
finish();
}

return super.onOptionsItemSelected(item);
}

quand je clique sur un menu et bah il bloc et il m'affiche une erreur:

preocess com.exemple.android has stopped unexpectedly please try again.
comment je peut regler ce problem???

1 réponse

scinarf Messages postés 1098 Date d'inscription samedi 18 novembre 2006 Statut Membre Dernière intervention 25 septembre 2014 291
6 févr. 2013 à 14:52
Bonjour,

Je viens d'avoir une erreur avec les Intent également, malgré le sujet pas tout jeune, je fourni quand même une réponse.

Alors pour utiliser les Intent:

Il faut déclarer dans AndroidManifest toutes les activités utilisés:
exemple:
j'utilise MainActivity en 1ere Activité et SecondActivity en 2eme ce qui donne dans le manifest:

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:debuggable="true" >
<activity
android:name="com.example.bluetoothcom.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity" />
</application>
0