Page de demarrage

bouchrot Messages postés 352 Date d'inscription mercredi 12 octobre 2011 Statut Membre Dernière intervention 2 janvier 2023 - 16 juin 2019 à 14:06
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 - 19 juin 2019 à 12:03
Bonjour,
sous un programme android comment puis-je choisir quel page sera au lancement du programme
merci

1 réponse

Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
Modifié le 19 juin 2019 à 12:04
Salut,

Dans le fichier AndroidManifest.xml il faut ajouter le filter ci-dessous dans l'activité que tu veux par défaut:
<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> 
 


Exemple avec deux activity dans le manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package=".....">
   ... permission ...
   
    <application
        android:name="xxxxxx"
        android:testOnly="false"
        android:allowBackup="true"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name=".MyActivity"
            android:launchMode="singleTop"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".MySettings"
            android:parentActivityName=".MyActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".MyActivity"/>
        </activity>
    </application>
</manifest>




0
Rejoignez-nous