Which Android library determines the application and the activity which initially launches?

StackOverflow https://stackoverflow.com/questions/22990102

  •  01-07-2023
  •  | 
  •  

Question

I am experiencing my first taste in android development. Took me sometime to get the environment set-up and to load the current project. I am reviewing the project and I'm lacking the knowledge in recognizing the basics.

I actually referred to the auto-generated AndroidManifest.xml to determine which class started the application and which one initially launches. I reviewed the files inside their respective packages and I am trying to determine which imported libraries are determining this.

For the application, I think it's pretty obvious:

import android.app.Application;

Here is a snippet of the AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nlrt.sanome"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="18" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <!--
        TODO: I should look into this warning about allowing backup:

            Should explicitly set android:allowBackup to true or false (it's true by default, and that can have some security 
            implications for the application's data)
    -->
    <application
        android:theme="@style/sanome_theme"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:name="com.menus.SanoApplication" >



        <!-- LOGIN -->
        <activity
            android:name="com.login.LoginActivity"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateAlwaysVisible|adjustResize"
            android:label="@string/title_activity_main_login" >

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

        </activity>



        <!-- MENUS -->
        <activity
            android:name="com.nlrt.sanome.menus.MainMenuActivity"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.nlrt.sanome.menus.SubMenuScreeningToolsActivity"
            android:screenOrientation="portrait" />

Now since this is my first time looking at this code, I actually had to refer to the AndroidManifest.xml to know which file launched the application. This file is auto-generated, so the library makes it realize that this is the application entry point of com.menu.SanoApplication is the previously mentioned library of android.app.Application. Is this correct? If not why?

The start up actually launches another file from a different package, I noted that in the manifest too. What is it that makes this (com.login.LoginActivity) to be recognized launch file? That the is the MAIN and LAUNCHER?

I am reviewing these files but I am lacking the knowledge to see how they are connected without the auto-generated file.

Thanks so much for any help that can be provided.

I am also looking for recommendations on a great beginner tutorial dealing with simple android application. Not one which details the steps to installation cause I got that done. Nor one that is helloworld - got that completed too. Does anyone have any better suggestions? Also one that references Netbeans IDE would be much appreciated.

Thanks Again for any help the can be provided.

EDIT // SOLUTION

The AndoridManifest.xml is not auto-generated. The link as provided by Lunchbox below states it very clearly. I was under the impression this file was created each time the Build action is performed.

Was it helpful?

Solution

Look at these lines:

<activity
        android:name="com.login.LoginActivity" ...>

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

You used intent-filter to tell Android that your LoginActivity should be shown to user on application startup: the MAIN action specifies the LoginActivity as an entry point of your application, and the LAUNCHER category tells android that this entry point should be listed in your Launcher's top level list of applications.

As for recommendations, I would highly suggest The Busy Coder's Guide to Android Development. It is monumental.

OTHER TIPS

Is this correct?

Not by my definition of "entry point".

If not why?

An Application instance is not an "entry point". It is merely a singleton created as part of your process starting up, nothing more.

What is it that makes this (com.login.LoginActivity) to be recognized launch file? That the is the MAIN and LAUNCHER?

If by "to be recognized launch file" you mean "to have an icon show up the home screen launcher", then yes, the <intent-filter> on that <activity> is causing this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top