Android Application Architecture (Android Dev Summit 2015)

Android Developers · 143K views · 2015 · 41:42

Open on YouTube

Software architecture & designSoftware practice, open source & careerstalkdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering architecture questions about MVP, activity and fragment lifecycles, background tasks and syncing data, because it comes from Google engineers and comes with a sample project.

Recommended by 8 people across 6 different months, 2015 to 2017.

What it is

A 2015 Android Dev Summit talk by Google engineers Yigit Boyar and Adam Powell on structuring Android apps. It covers patterns for lifecycle handling, background work and syncing data, with a demo app whose source is published on GitHub.

What people said

Strong rec Aitor Viana · 2015-12 · Stack Overflow · on “Android MVP explanation”

first thing I wanted to clarify is that MVP or any other pattern for that matter is no specific of Android dev and, can be applied to any other framework. I think you got the gist of it: view is usually implemented by activities and fragments and will contain the reference to the presenter the presenter is that middle man between the view and model. Retrieves data from the model and returns it already formatted to the view so it doesn't need to do anything else but display it. the model can be seen in a simplistic way as the "data provider". It can be as complex as you want, using internal db, lots of clases etc. If you are interested in Android apps architecture I suggest you watch this tal

Recommends brwngrldev · 2015-11 · Stack Overflow · on “Why we Choosing Fragment over Activity?”

1) You don't have to use fragments if you don't feel they are necessary for your application. 2) Having multiple activities is fine. Most applications do. 3) Having fragments inside fragments is permissible, but you should just be aware that it can cause odd behavior in your application if you are not familiar with the lifecycle events. 4) In the Android Dev Summit (2015), a great overview of a sample Android architecture was presented, I encourage you to view it: here [this video] Hope this helps to clarify things some.

Recommends rupesh jain · 2015-12 · Stack Overflow · on “How to implement communication Activity-Service”

You might consider optimistic rendering / optimistic updates - A pattern in which you update the UI on client as if it has being successful on the server. Once you get response from the server you update the UI accordingly.You can refer apps with new designs like google hangouts. [LINK] For more info refer this discussions: what is `optimistic updates` in front-end development [LINK] [LINK] I guess using this approach will give better usability to your app. The current implementation looks ok. However you can improve it by following this talk- [this video]

Recommends riggaroo · 2015-12 · Stack Overflow · on “Android MVP explanation”

I wouldn't say MVP works perfectly for *every* application of android. It depends entirely on what you want to do. I have used MVP for my own android app and I think it cleans up the code heavily, from having the bulk of the code in your Activities and Fragments. That being said, there was an interesting talk from Yigit - [this video] which doesn't seem to use MVP. Another really interesting article can be found here about MVP: [LINK]

Recommends Héctor Valls · 2016-01 · Stack Overflow · on “How to sync SQLite database in an Android app, when the data changes on MySql Database Server”

There are some solutions. You can use push notifications using Parse [LINK] , for instance, when your MySQL changes. Or you can use JobManager to enqueue custom synchronization tasks. I recommend you to see this video [this video] and check out the video project: [LINK] This reflects your problem very good and it is a very nice solution and, the most important, it is developed by a Google employee. I hope it helps you!

Recommends Eugen Pechanec · 2016-02 · Stack Overflow · on “Restore Android GridView after screen orientation change (without reloading it)”

@MouradJEMAÏL You just made my day :D Glad I could help. Now I recommend focusing on loading the items from internet effectively. You could look at this [this video] (although it might be a bit heavy duty). Since you have a new activity instance for every config change, you can't rely on simple async task which is tied to its original activity. Good luck!

Recommends J.D.1731 · 2016-10 · Stack Overflow · on “Stop AsyncTask when fragment is replaced”

It's not so simple, please consider the situation when your fragment is going to back stack, then you can reach methods onPause() and onStop() . User can either come back to this fragment in a second when AsyncTask is still running. Then it could be not really efficient to call AsyncTask once again. There is actually two options, first one is the Syncing architecture solution when you're syncing your model separately from visible fragments, then you don't have to cancel AsyncTask but it requires to change your application logic. You can hear about it on Android Application Architecture (Android Dev Summit 2015) [this video] As the lecturer said, it's not so important what kind of architecture you

Recommends humazed · 2017-04 · Stack Overflow · on “Keep track of item in recylerview?”

The easiest solution -but not the most correct one- would be as the following: add a boolean attribute isSuccessful to the message class. when you send the message and the get the response back from the server change the corresponding message. and call notifyDataSetChanged on the Adapter. and I recommend this take [this video] where they build this open source messing app [LINK] to get a better understanding how to design you Application Architecture, as my solution is not the best but I guess is the easiest.

Cites shanraisshan · 2015-05 · Stack Overflow · on “Passing parameters vs Allocation inside function, memory-leak in java/android?”

2 Different ways of doing the same thing (i.e Fetching messages from Database) Scenerio 1 Calling Class: ArrayList<String> messages = new ArrayList<String>(); messages = Db.getAllMessage(messages); Database Class: public ArrayList<String> getAllMessage(ArrayList<String> m) { m= /* get messages from DB */ return m; } Scenerio 2 Calling Class: ArrayList<String> messages = new ArrayList<String>(); messages = Db.getAllMessage(); Database Class: public ArrayList<String> getAllMessage() { ArrayList<String> temp = new ArrayList<String>(); temp = /* get messages from DB */ return temp; } My Question is, in Scenario 2 , What will happen to temp ArrayList variable, Will it remain in memory until the a

Cites RobertoAllende · 2016-08 · Stack Overflow · on “invoke a method from activity in another”

Activities in Android are no just a simple class but they also have a Lifecycle [LINK] : An activity has essentially four states: If an activity is in the foreground of the screen (at the top of the stack), it is active or running. If an activity has lost focus but is still visible (that is, a new non-full-sized or transparent activity has focus on top of your activity), it is paused. A paused activity is completely alive (it maintains all state and member information and remains attached to the window manager), but can be killed by the system in extreme low memory situations. If an activity is completely obscured by another activity, it is stopped. It still retains all state and member info