public class UApplication extends Application{ private static UApplication mApplication; @Override public void onCreate() { super.onCreate(); mApplication=this; } public static UApplication getInstance() { return mApplication; } }
<application android:label="@string/app_name" android:allowClearUserData="true" android:name=".UApplication" android:theme="@android:style/Theme.Holo.Light" android:icon="@drawable/ic_launcher"> <activity android:name="MyActivity" android:launchMode="standard" android:windowSoftInputMode="adjustResize" android:icon="@drawable/back6" android:label="主頁"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".TAct" android:icon="@drawable/logo" android:parentActivityName=".MyActivity" android:label="TAct"> </activity> <service android:name=".MService"/> </application>
<application android:allowClearUserData=["true" | "false"] android:label="string resource" android:icon="drawable resource" android:name="string" android:allowTaskReparenting=["true" | "false"] android:backupAgent="string" android:debuggable=["true" | "false"] android:description="string resource" android:enabled=["true" | "false"] android:hasCode=["true" | "false"] android:killAfterRestore=["true" | "false"] android:manageSpaceActivity="string" android:permission="string" android:persistent=["true" | "false"] android:process="string" android:restoreAnyVersion=["true" | "false"] android:taskAffinity="string" android:theme="resource or theme" > <activity android:name="MyActivity" android:launchMode="standard" android:windowSoftInputMode="adjustResize" android:icon="@drawable/back6" android:label="主頁"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".TAct" android:icon="@drawable/logo" android:parentActivityName=".MyActivity" android:label="TAct"> </activity> <service android:name=".MService"/> </application>