-2

Having programmed for just over 6 months in Java i decided to give android a shot,but it looks like android merely uses the Java Syntax and all else differs

Example: I can see under app/src/java/MainApplication... that The Activity MainApplication extends Activity and has onCreate() methods etc , but what i don't get is how all this works, which method in the launcher activity runs first and how?

Can you draw an analogy between java Programs in Jar files ,say like how the class declared in manifest is launched and its main method runs and how android works?

I find the whole Android framework to be very different and confusing compared to the Java, Swing, AWT and event handling model of what i practiced so far, Please help!

How is onCreate() called without creating an instance of the class and calling the method on the Object, how is it called without an Object as the method is not static too?

PS:I'm taking Udacity's android course

Sainath S.R
  • 3,074
  • 9
  • 41
  • 72
  • This is a platform for concrete programming questions - not for "explain me the world because I don't want to study by myself" type of questions. There are so many good resources to learn how Android works - read them please. – Carsten Dec 22 '14 at 10:24
  • Android apps. are more like an applet in this sense. They have methods that are called automatically by the virtual machine. – Andrew Thompson Dec 22 '14 at 10:24
  • @Carsten Still i would appreciate it if someone gave me the idea in a nutshell – Sainath S.R Dec 22 '14 at 10:25
  • http://developer.android.com/training/basics/activity-lifecycle/starting.html http://stackoverflow.com/questions/19538976/what-is-a-oncreate-method-in-android – Carsten Dec 22 '14 at 10:26

1 Answers1

3

Basically it works as follows:

  1. Application entry points such as activities are declared in the manifest file and it is bundled with the application APK.

  2. The activity class is instantiated by name declared in the manifest, using reflection.

  3. The class instance is set up (e.g. Context, Configuration) and its onCreate() and other lifecycle methods are called.

For code-level details, see e.g. performLaunchActivity() in ActivityThread.

laalto
  • 150,114
  • 66
  • 286
  • 303