Hacker News new | ask | show | jobs
by lanestp 3694 days ago
I agree. Android architecture is a mess. Activity life cycling is actually impossible. There are certain actions the OS takes that will cause crashes no matter how well architected the app is.

My main quibble with Android is that since everything is tied to the activities it is impossible to build an MVC style app. You are better off using the NDK or an engine. Then you can build your software correctly.

3 comments

Do you mind expanding on some of your statements? Especially:

> Activity life cycling is actually impossible. There are certain actions the OS takes that will cause crashes no matter how well architected the app is.

I work on a very popular app in Latin America. That means we get to experience every single edge case in the eco system. My favorite quirk has been that for some reason I will never understand when an app goes into a full screen ad it can make your main activity eligible for GC. That means that you don't get any of your Activity life cycle events. Just a lone finalize and your app is gone. Then when the video ad is done you get a truly spectacular crash!

Sadly, I have a half dozen different ways activities have found to explode themselves. It makes me sad!

Sounds like the video ad is a new activity? Since it's full screen, your main activity is no longer visible so you should be seeing onPause and onStop fire. Are you saying you don't see them?

Also, I'd imagine video ads are also quite memory intensive, so if a low-RAM device is playing one I wouldn't be surprised if Android has to kill some processes (like your activity that was sent to the background) to make space.

Perhaps you should look into what these video ads are doing and what sort of resources they eat up?

How would the ndk help, doesn't it run within an activity?
I use the NDK a lot because you can kind of ignore the Android nonsense and structure your code properly. My approach is to have it build out the main activity then fire out into my app code. That code is beautifully MVC and for the most part ignores Activities, Fragments and Intents. For me it was faster to develop in than Android Java because I wasn't so strongly tied to the view code.
Why do activities make it hard to do MVC? They seem similar to UIViewControllers on iOS.