简体   繁体   中英

Problem when I try to open another window from a button the app closes completely "Android Studio"

i'm a student and i'm working on a mobile app. The probleme is that my app was working, but now when i click on the button to open another window it closes. Here is my code: `

   public class MainActivity extends AppCompatActivity {
    Button b_inscrire_etudiant;
    Button b_inscrire_enseignant;
    Button b_inscrire_admin;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        b_inscrire_etudiant = findViewById(R.id.b_inscrire_etudiant);
        b_inscrire_enseignant = findViewById(R.id.b_inscrire_enseignat);
        b_inscrire_admin = findViewById(R.id.b_inscrire_admin);

       
        b_inscrire_etudiant.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(MainActivity.this , InscriptionEtudiant.class);
                startActivity(i);
            }
        });

        b_inscrire_enseignant.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(MainActivity.this , InscriptionEnseignant.class);
                startActivity(i);
            }
        });

        b_inscrire_admin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(MainActivity.this , InscriptionAdmin.class);
                startActivity(i);
            }
        });

    }
   }

`

I worked as usual "using Intent" besides it worked well until now.

Here is my Manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.myusto">

<application
    android:allowBackup="true"
    android:dataExtractionRules="@xml/data_extraction_rules"
    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/Theme.MyUsto"
    tools:targetApi="31">

    <activity
        android:name=".InscriptionEnseignant"
        android:exported="false">
        <meta-data
            android:name="android.app.lib_name"
            android:value="" />
    </activity>

    <activity
        android:name=".InscriptionEtudiant"
        android:exported="false">
        <meta-data
            android:name="android.app.lib_name"
            android:value="" />
    </activity>

    <activity
        android:name=".InscriptionAdmin"
        android:exported="false">
        <meta-data
            android:name="android.app.lib_name"
            android:value="" />
    </activity>

    <activity
        android:name=".Connexion"
        android:exported="false">
        <meta-data
            android:name="android.app.lib_name"
            android:value="" />
    </activity>

    <activity
        android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

</application>
</manifest> 

ps: I solved the problem, by the way two were missing

Thank you for the answers. It's true, it was missing a part of the code which was not written in the manifest file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM