KIO
Kreative Ideen online
AndroidManifest.xml

AndroidManifest.xml

Every Android app must include a file called AndroidManifest.xml. You can find it in the app/src/main folder of your project. The AndroidManifest.xml file contains essential information about your app, such as what activities it contains, required libraries, and other declarations. Android creates the file for you when you create the app.

Every activity needs to be declared:
All activities need to be declared in AndroidManifest.xml. If an activity isn’t declared in the file, the system won’t know it exist. And if the system doesn’t know it exists, the activity will neve run.

You declare an activity in the manifest by including an <activity> element inside the <application> element. In fact, every activity in your app needs a corresponding <activity> element.

Example:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="eu.kio.mymessenger">      <!-- This is the package name we specified --> 


    <!-- 
        android:icon="@mipmap/ic_launcher" : Android Studio gave the app default icons
        android:roundIcon="@mipmap/ic_launcher_round"  : Android Studio gave the app default icons  
        android:theme="@style/AppTheme" : The Theme affects the appearance of the app.
    -->

    <!-- Each activity needs to be declared inside the <application> element -->
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <!-- 
            This is the first activity, Create Message Activity.
            This line is mandatory
             .CreateMessageActivity  it's prefixed with a "." because Android combines the class name
            with the name of the package to derive the fully qualified class name
         -->
        <activity android:name=".CreateMessageActivity">
            <intent-filter>
                <!--
                   This bit specifies that it's the main activity of the app
                -->
                <action android:name="android.intent.action.MAIN" />
                 <!-- 
                     This says the activity can be used to launch the app
                  -->
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>    
        <!-- 
            This is the second activity ReceiveMessageActivity. Android Studio added this code when 
            we added the second activity 
            This line is mandatory 
        -->      
        <activity android:name=".ReceiveMessageActivity"></activity>
    </application>

</manifest>

If you develop Android apps without an IDE, you’ll need to create this file manuall.

Leave a Reply

Your email address will not be published. Required fields are marked *