49

Is this OK to understand that Activity is similar to ViewController in iOS?

I am confused to accept a concept of terms in Android as Activity, Service etc...

Mat
  • 202,337
  • 40
  • 393
  • 406
Jeff Gu Kang
  • 4,749
  • 2
  • 36
  • 44

1 Answers1

40

Yes, I would say that Activity and ViewController are rather similar. There is just one BIG difference. In iOS you have a delegate to control your application's state, like a new ViewController has started or the application is finished. In Android you do this separately for each activity via onCreate(), onPause(), etc.

iraSenthil
  • 11,307
  • 6
  • 39
  • 49
superM
  • 8,605
  • 8
  • 42
  • 51
  • 28
    Actually, I would say that both iOS `ViewControllers` and Android `Activities` have their lifecycle methods. For example an equivalent of `ViewController.viewDidLoad()` is `Activity.onCreate()`. And the equivalent of iOS `ApplicationDelegate` is Android `Application` subclass (however this subclass is not obligatory in an Android project, one can add it if it is necessary). Of course there are some differences in how these equivalents work but the main concepts are very similar in both platforms. – Piotr Aug 20 '11 at 16:25
  • Separating activity lifecycle from view control can also be performed by using an activity that extends your own custom activity (that inherits directly from Activity). However, I've never been very strict about this approach, and it may not apply in the new Fragments paradigm. – Rich Ehmer Oct 02 '12 at 13:43
  • 4
    I think there is a main difference, in android there is only one Activity on top while in ios you can have multiple ViewControllers running. For example if in android an activity has a media player playing some audio and you start another activity the player will stop playing. But in iOS you can have a view controller playing it's audio while another is presented on top. – Sina Rezaei Jun 25 '17 at 07:13