Extending Application to share variables globally

To elaborate on Peter K’s answer, you do not need to create a second <application> section for your derived Application class. You simply need to “rename” your existing <application> section by amending it with the android:name tag. I also want to point out that the fully qualified classname is required(as you’ve done correctly…I found this out the hard way).

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myname.bpstattracker" android:versionCode="1"
    android:versionName="1.0">
    <application android:name="com.myname.GlobalVars" android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".BPStatTracker" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".BPSTAdd"></activity>
        <activity android:name=".OneOrThree"></activity>
        <activity android:name=".SixOrTen"></activity>

    </application>
</manifest>

Leave a Comment