branch4 Blog

Internet development with every single possibility.

[Android] Entry Point of Android Program

| Comments

There’s no main function in Android programming.
Many people notice that. So where’s the entry point ?
It’s pointed in AndroidManifest.xml file.
There are many things written in this file so I’ll go into the details in other articles.

For now, example below will be enough.

    
      <?xml version="1.0" encoding="utf-8"?>
      <manifest
        xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.XXXX.testApp"
        android:versionCode="1" android:versionName="1.0" >
      <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
      <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
      <activity
        android:name="com.xxxx.yyyy.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>
      </application>
      </manifest>
     
In above manifest, the activity with, the intent-filter below will be listed in the system launcher, and would be the entry point for that icon.
    
      <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
     
In detail,
    
      <action android:name="android.intent.action.MAIN" />
     
–>this line sets the entry point

    
      <category android:name="android.intent.category.LAUNCHER" />
     
–>this line sets the app to the launcher

This could be set to multiple activities.
I think facebook once used this with their messenger.


Comments