No. An Activity is just one of the components that make up an application (package).
http://developer.android.com/guide/topics/fundamentals.html#Components http://developer.android.com/guide/topics/fundamentals/activities.html Since you have a receiver for boot_completed, and there is an event for it, your package is brought into memory and run as a process. This is needed so you can get BOOT_COMPLETED in your receiver's onReceive. After this, the process is left in memory as a cache. But at this time, the user hasn't started any activities, so there aren't any. As soon as the the user goes to the application drawer to run your app, or uses a status bar notification that resolves to an activity, etc - the approprate activitiy will be 1) constructed 2) initialized with onCreate 3) go on doing its thing, interacting with the user. Until then, no. -- Kostya 2011/6/12 Simon Platten <[email protected]> > During testing, I have shutdown all processes including the application > before shutting down the phone. > > When I power up the phone I can see that the application has been restarted > and is resident, so I should be able to get the activity shouldn't I? > > > > On 12/06/2011 9:51 AM, Kostya Vasilyev wrote: > > There may not be an instance of your activity - definitely not when we're > talking about processing boot_completed. > > At that point, the only components involed are a broadcast receiver and > possibly your wakeful intent service (IIRC). Since the user at that point > has never run your application, there aren't any activities that have been > constructed. > > So - don't rely on an instance of Activity subclass to initialize your > statics. > > You can use a lazy-initializable singleton (mine and many others' preferred > solution) or use an Application subclass and its onCreate method. > > -- Kostya > 2011/6/12 Simon Platten <[email protected]> > >> Hi, >> >> I've managed to find out why my application wasn't restarting correctly >> after a boot up and it was an uninitialised array that is normally set-up by >> the main activity when the application starts. >> >> The question now is....how do I get the main application activity? >> >> The reason it isn't so straight forward is that I've created a library >> which I use in several similar applications, in the library I have a base >> activity class which provides core functionality, in that class I have >> defined an abstract method called 'setupArray'. >> >> The name of the derived activity class may be different in each >> application. What I would like to do is get a reference to the application >> activity from within the library then call the setupArray method to ensure >> the array is set-up from the reboot onReceive method. >> >> Does that make sense? >> >> -- >> Regards, >> Sy >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

