anitaa1990 / android-cheat-sheet Goto Github PK
View Code? Open in Web Editor NEWCheat Sheet for Android Interviews
License: Apache License 2.0
Cheat Sheet for Android Interviews
License: Apache License 2.0
Dont bother learning from this, atleast the android part has lot of mistakes.
Some examples:
"There are 3 CPU architectures in Android" - this is wrong. https://developer.android.com/ndk/guides/abis
"Android uses DVM (Dalvik Virtual Machine )" - no, its ART (android runtime)
"What is the Android Application Architecture?" - missing the ABSOLUTELY most important thing: ACTIVITY
"OnPause(): Called as part of the activity lifecycle when an activity is going into the background, but has not (yet) been killed." - wrong, onpause is called when an activity loses focus (for example a popup appears). It MIGHT indicate that its going to background.
Those are mistakes i found in 3 minutes, didn't bother to continue after that.
Eg: Suppose there is an activity stack of A -> B -> C -> D. If we launch activity B again with the launch mode as “singleTask”.
should be updated to
Eg: Suppose there is an activity stack of A -> B -> C -> D. If we launch activity D again with the launch mode as “singleInstance”.
How does the activity respond when the user rotates the screen?
When the screen is rotated, the current instance of activity is destroyed a new instance of the Activity is created in the new orientation. The onRestart() method is invoked first when a screen is rotated. The other lifecycle methods get invoked in the similar flow as they were when the activity was first created.
When rotation changes;
onPause()->OnStop()->OnDestroy->OnCreate()->onStart()->OnResume()
Hey! These are a great set of notes, and I'm sure they'll be really helpful as a "cheat sheet" as you noted :)
There are a few issues that I've found, however. For example:
Android service is a component that is used to perform operations on the background such as playing music. It doesn’t has any UI (user interface). The service runs in the background indefinitely even if application is destroyed.
Which isn't entirely true. First, pre-Android 8.0, Services can continue to run in the background even if Activites are destroyed, but the Application is still alive (and hosting the Service, as one can see by calling getApplication()
).
It also talks about IntentService
, but there isn't a mention of JobIntentService
or WorkManager
. I think it would be valuable to add these to the discussion given they are better suited to work with the background restrictions on Android Oreo and beyond.
There's also:
The most basic approach is to add an element attribute tag android:configChanges inside the activity tag in the AndroidManifest.xml.
android:configChanges="orientation|screenSize"
. But the cleaner thing to do is to useOnsaveinstancestate
to save the data and retrieve it when onCreate is called again.
I think this could benefit from potentially discussing (or at least pointing out) ViewModels?
There is also a lot of great information here that I think could really benefit from cross-linking. That is, take the following points:
Thread should be used to separate long running operations from main thread so that performance is improved. But it can't be cancelled elegantly and it can't handle configuration changes of Android. You can't update UI from Thread.
and
Handlers allow communicating between the background thread and the main thread.
Taken separately they're great nuggets, but if there were some way to link them (I'm not sure the best way, sadly, or I would have simply opened a PR), it might be even more helpful, especially for newbies. (i.e.: You can't update the UI from a Thread, but it's possible to post a Message from a Thread to the UI thread's Handler and update the UI that way...) sort of thing.
I could also imagine it being very useful to link to some things on developers.android.com from here, so that if someone were just learning about a, for example, PendingIntent, they could click it to get the reference documentation on the class. :)
In any case! There's a lot of great stuff here, and I think that you could make it even better with some of these updates. (Sorry that I'm not being complete with my assessment. I only read about this on Reddit today and haven't gone through it in a lot of detail.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.