In my Android application, I have a DefaultApplication class that extends android.app.Application , and in onCreate() I bind some services that will be used by my other actions in this application.
I also have a BroadcastReceiver that listens and receives C2DM messages. When this receiver receives a message when the application is not running, it will launch a dialog box in which the following message will be displayed, and it will start the action of my application.
My question is, when I start activity without any interaction with DefaultApplication , will my DefaultApplication onCreate() be called because the activity of this application has started?
Here is the definition and manifest of my DefaultApplication :
public class DefaultApplication extends Application { @Override public void onCreate() { super.onCreate(); doBindService(); } void doBindService() {
The manifest looks like this:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name="com.mypackage.DefaultApplication" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:debuggable="true"> <service android:name="com.mypackage.services.SocketService"></service> <activity android:name="TestActivity" android:screenOrientation="landscape"></activity> </application>
android android-activity oncreate application-lifecycle
Yasin YILDIRIM Oct 07 '11 at 11:15 2011-10-07 11:15
source share