• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Head First Android

 
Ranch Hand
Posts: 583
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi ,
I've read your previous book "Head First Android second edition" and found it useful.
It seems like the main difference between that and the new edition is the new edition seems to focus on using Kotlin rather than Java as the coding language. Is that a fair assessment or , as a reader of your previous edition ,would I get more out of the book than that ?

I'm not an Android expert but , so far , the main problem I see with Android is the platform itself rather than the particular coding language. The API's are really inconsistent and it is a very glitchy platform to code in . I've actually spent months off and  on working around a problem with the MediaControl bar that disappears after 3 seconds . It seems like that "feature" was an intentional decision by the designers but the documented options to work around it - like "show(0)" only work  sometimes but not others.

Thanks,
Paul
 
Author
Posts: 143
15
Android Python Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Paul,

Kotlin is one of the changes, but there are many, many other as well. Such as the use of Jetpack (not just Compose, but the other libraries as well).

The APIs most certainly can be complex, and sometimes the design choices can seem... interesting. Fortunately, they do seem to have embraced a lot of the power of languages like Kotlin, and if you've had the chance to work with Jetpack Compose, you'll have seen how the compiler architecture allows them to greatly simplify the way components can be made, and then plugged together to form apps.

It certainly feels like a good time to be getting back into Android development.

D+D
 
paul nisset
Ranch Hand
Posts: 583
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David.
I don't know anything about Jet Pack or Compose . Sounds like I would benefit from learning about them.

I agree that Android has changed a lot . How lists are handled was a big change. I tried to download the source code for the MediaController but the most recent version I could find  was several years old and the compiler didn't recognize several core classes that were part of it.  

Do you know if there is a place you can download the current source code for various Android libraries  ? My goal with downloading the MediaController source was to create and use a custom MediaController class without the 3 second disappearing act.

The updated book sounds pretty useful. Good luck with it.

Paul
 
David Griffiths
Author
Posts: 143
15
Android Python Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Paul,

If you try:

https://source.android.com

It might be in there.

We've noticed that many developers have started to use the ExoPlayer open source project because of some of the peculiarities of MediaPlayer (I think the last time I checked, it couldn't follow redirects when streaming URLs...?). Even Google are now suggesting people use it:

https://developer.android.com/guide/topics/media/exoplayer

BTW: bad news, re: lists.... They change *again* in Jetpack Compose. However, they get *significantly* simpler. Instead of having to worry about adapters and recyclers and etc... you can instead use a thing called a LazyColumn (or LazyRow) to generate lists. This is an example piece of code from the Jetpack Compose course next week:



It creates something like a RecyclerView, but in a fraction of the amount of code you would have needed previously.

D+D
 
paul nisset
Ranch Hand
Posts: 583
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the info David.
I'll check out source.android.com and ExoPlayer . There are certain things with android that I think "Really? This should not be this involved ..." The change to Recycler View was one of them . I kind of understand the reasoning why they made a change to using Recycler  but, man, it is just a list . It's good the latest change is simpler.

The code looks interesting . It reminds me of Hibernate Lazy initialization . Probably to manage memory use . I guess the TaskItem is a particular list item/object that isn't loaded into memory until you click on it.
It will be interesting to learn about this change.

-Paul
 
David Griffiths
Author
Posts: 143
15
Android Python Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Paul,

Yes, TaskItem is an example "component" that displays the details of a task (the app is a task management app). The LazyColumn is built using the items(<list size>) call, and the code that follows it:



Is called each time a "row" is exposed on the list. The "it" variable will contain the index of the item to display, and the call to TaskItem just displays the relevant task.

It's a very different model of app development, but once you get used to it, it is significantly easier to do. Instead of having large Java classes that somehow get associated (such as recycler views, adapters, view-holders) you just have small functions that emit bits of the interface.

D+D
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me. I'm reading book head first android development. And i'm on the 8-th chapter. So and i'm performansing exercies but there used library appcompact-v7:25.3.0. I just ignored it cause i use android studio Koala 2024. Then i met this fragment of code  <android.support.v7.widget.Toolbar> and this is invalid. Wihch one i need replace it so that it works like in the books? Thank you for attention!!!
 
paul nisset
Ranch Hand
Posts: 583
3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is a common issue that will come up repeatedly as you develop with Android. Android is not backward compatible.

When you come across issues like this , think in terms of libraries and components.
"android.support.v7.widget.Toolbar" is the  "toolbar" component in in the "android.support7" library .
You need a more current library for the Toolbar component  that is compatible with the version of android that you are using to compile and targeting as output.

To find out what you need remember : Google is your friend. Textbooks and tutorials in android are often out of date by the time you read them.

Here is a result I got  that uses a more recent library . They use 'androidx' instead of 'android' .

https://stackoverflow.com/questions/36233798/android-support-v7-widget-toolbar-is-not-found-in-java-file-using-android-studio.

good luck.
 
For my next trick, I'll need the help of a tiny ad ...
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic