Skip to content

Should be updated for Android 8.0+ #2

@nic0lette

Description

@nic0lette

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 use Onsaveinstancestate 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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions