• Breaking News

    Thursday, May 5, 2022

    Android Dev - [Book] Jetpack Compose internals

    Android Dev - [Book] Jetpack Compose internals


    [Book] Jetpack Compose internals

    Posted: 04 May 2022 02:52 PM PDT

    The first stable release of Jetpack Compose was released in July 28, 2021. The same day, I pre-launched a book called "Jetpack Compose internals", after having worked on it very consciously for around half a year. My main goal with this book was to fill an existing knowledge gap about this topic, since it was (and it still is) very hard to find any literature about it on the Internet. My second goal was to satisfy my own curiosity and put my ideas in order, since writing is one of the most efficient ways to learn.

    My intuition told me that such a topic would be likely embraced by the community. That is because one of the things that I have learned over the years as an Android developer (and that still remains true) is that reading source code and diving into platform internals can result in a huge leap in knowledgeability and your ability to face the development of new complex features. In the world of Views there was definitely a lot of this, every day. And it is not different for Composables. I thought people would appreciate this.

    After a huge amount of work, the book is quite close to its final version now. It currently covers the following chapters:

    • Composable functions in depth.
    • The Compose compiler.
    • The Compose runtime.
    • Compose UI.
    • The State snapshot system.
    • Effects and effect handlers.
    • Advanced Compose use cases.

    That is around 200 pages so far. Each one of these chapters is very complete and provides highly detailed and deep knowledge about its corresponding topic.

    Since I started writing this book until today, I've kept one key point in mind: It needed to be clear and accurate. I didn't want it to become some half-baked vague theory that no one would believe. If I was going to talk about internals, the book should be concise, correct, and accurate. Otherwise what is the point? For this reason, I asked the Google developers from the official Jetpack Compose team to review every single chapter. And they politely agreed, and helped so much. The result of this is awesome, and really rewarding for me.

    On top of the mentioned chapters, one or two additional chapters will be released before the book is 100% complete. You can go to jorgecastillo.dev/book for a complete table of contents.

    The current price is $39,99 with an option to pay more if you want to support me even more. Regardless of how much you decide to pay, it will be really appreciated, since you'll give me the means and motivation to keep writing. This price will raise soon, when the book is complete. If you purchase it now you'll get all the updates, the same day they are published.

    You can buy the book here.

    I didn't want to end this post without saying thanks to all the people who purchased the book so far. The amount of people supporting it is nuts, I could have never imagined such a wide acceptance.

    Feel free to ask any questions about the book here, I'll happily answer them.

    Jorge.

    submitted by /u/jorgecastilloprz
    [link] [comments]

    Creating reliable tests for Android notifications

    Posted: 04 May 2022 08:20 AM PDT

    How should MVVM handle data consistency?

    Posted: 04 May 2022 10:35 PM PDT

    Let's say in the Facebook news feed, I open the comments section of a post and click like. Then, when I close the comment bottom sheet, the post shows that I have liked it. How does it work with MVVM? When the post is liked in the comments section, would I have to refetch the entire news feed?

    submitted by /u/1298se
    [link] [comments]

    Can't figure out how to save a list of objects in Room

    Posted: 04 May 2022 05:55 PM PDT

    I'm ashamed to admit it but I've been stuck on this problem for a month now. Everyday I wake up I try to learn something new about this topic but after all the stackoverflow questions I think I have confused myself too much lol. If you have some time to spare to take a look at it I would greatly appreciate it.

    The app and what I'm trying to do:

    It's an earthquake app and I want to insert the List<Feature> which holds earthquake data into Room so the user can access it when offline. I'm grabbing data from the API with retrofit and displaying it in a recyclerview and this works. I need to use SSOT if I understood it correctly so all the data is always taken from Room. I'm not really sure how I'm supposed to approach saving a list of objects in Room though in this scenario.

    This is the API

    interface EarthquakeApi { @GET("/earthquakes/feed/v1.0/summary/2.5_week.geojson") suspend fun getJishin(): Response<EarthquakeResponse> } 

    Parent data class (I only need the data from List<Feature>)

    data class EarthquakeResponse( val bbox: List<Double>, val features: List<Feature>, val metadata: Metadata, val type: String ) 

    Feature data class (Bit misleading name but it represents data for each earthquake)

    @Entity data class Feature( @Embedded val geometry: Geometry, @PrimaryKey (autoGenerate = false) val id: String, @Embedded val properties: Properties, val type: String ) { 

    DAO

    @Dao interface EarthquakeDao { @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertAll(feature: Response<EarthquakeResponse>) @Query("SELECT * FROM feature") fun getEarthquakes(): LiveData<List<Feature>> @Delete suspend fun deleteEarthquake(feature: Feature) } 

    Things I'm confused about:

    - Am I supposed to make EarthquakeResponse an Entity as well? But if I do that doesn't it make it difficult to access the data? I read that saving whole lists in Room is a bad approach. I'm having trouble envisioning how this data is supposed to look like in Room visually.

    - Should I map the Feature data class to a domain layer instead and create a list there? I understood it as this should be done regardless for the purpose of clean architecture but I'm not entirely sure if that's the solution to this problem.

    - Should I use a TypeConverter for List<Feature>?

    - Is this a one-to-many relationship? Am I supposed to follow this principle instead?

    submitted by /u/kobebeefpussy
    [link] [comments]

    yelp android final interview

    Posted: 05 May 2022 12:36 AM PDT

    Looking for any advice or specific details I should expect in yelp's final interview for android(technical).

    submitted by /u/agile_mambo
    [link] [comments]

    Android 12 Network Permission removed ?

    Posted: 05 May 2022 12:11 AM PDT

    In Android 11 you can choose what apps have permissions to access the internet, i recently installed android 12 and noticed this option is missing from all the Android 12 roms i tried.

    does anyone know why it was removed ?

    submitted by /u/0sculum3stm0rtis
    [link] [comments]

    How to know that configuration changed is happened inside onResume and onCreate method

    Posted: 04 May 2022 10:33 PM PDT

    send image to server and get it back

    Posted: 04 May 2022 06:08 PM PDT

    hi, i want to send image displayed in imageView to server and get it back after some process is done to it

    is there any tutorial that explain this in a little details

    submitted by /u/moaaz3bdelsalam
    [link] [comments]

    Persuade me to cancel my Mac Mini M1 (16GB, 256GB) order.

    Posted: 04 May 2022 11:54 PM PDT

    Hi, I just ordered a Mac Mini M1 (16 GB, 256GB variant). I took a year off from developing services to focus on my study (Management degree). I purchased this machine on a whim. So, I have not do much research (except the performance and alternatives Mini PC. I don't have concrete conclusion on whether M1 chip is a good choice for my usage since some people say they regret buying this machine and others said it is their best decision).

    I am going to use it strictly for:

    1. iOS development (I am not an iOS dev but would love to learn, this is the reason why I bought Mac Mini instead of 50% cheaper Mini PC).
    2. Android development (I used to learn React Native but I plan to learn making native app, not sure where to start, is it Jetpack?).
    3. Front end web development (I used to write Angular for a decacorn company, but my personal choice is React)
    4. Back end web development (I used to write Spring, but I plan to learn write HTTP server natively, not sure if I am going to succeeded, multi-thread is all I know to handle connection, I am looking for Actor model example but has not find one)

    Should I buy the ones with 8GB of RAM? or should I buy a Mini PC for 50% less (and maybe do a Hackintosh)?

    submitted by /u/kidfromtheast
    [link] [comments]

    Setting up app review credentials for Google when using Google login

    Posted: 04 May 2022 08:08 AM PDT

    My app use Google authentication. How do I add test account credentials for app review team. I tried adding a dummy Gmail account id and password.

    But they're constantly removing my app frequently for this issue without any warning. What am I supposed to do? Should I create a manual email and password based authentication system just for em?

    submitted by /u/Homeless_Programmer
    [link] [comments]

    Download statistics reports not updating since 2 weeks

    Posted: 04 May 2022 05:43 PM PDT

    Download statistics reports not updating since 2 weeks

    All csv reports under Download Reports > Statistics have stopped updating since 20th April. Same for everyone? Is this something that is being/has been sunset?

    Everything is still tracking as far as I can tell - when I navigate via All Apps > Statistics I can see we still have up to date data. But I want the data from the standard reports, not those dashboards areas etc.

    https://preview.redd.it/kfnzyunzzjx81.png?width=288&format=png&auto=webp&s=b683c8692106a3c467ba2b8d7115a13be4d2dfda

    submitted by /u/back-off-warchild
    [link] [comments]

    What questions should I ask of a company when I want to get an Android app developed

    Posted: 04 May 2022 11:51 AM PDT

    I would like to have a company create an Android app for me. It would be similar to another app that I have seen on the App Store that is used for storing personal notes. Most likely it would be very difficult to make any money with this app however I would still like to have a company create an app for me based upon ideas from a number of different personal note apps.

    Can someone give me advice on how best to do this, what questions to ask and any other advice they can think of.

    Thanks

    submitted by /u/dotnetmaui
    [link] [comments]

    Can we implement a custom low-level sound effect filter to be applied to all audio outputs?

    Posted: 04 May 2022 11:09 AM PDT

    Hi,

    I have a Java function whose input is signed 16-bit stereo channel waves (as two short[] arrays) and whose output is also the same. This function looks like this:

    void SoundEffect(short[] leftChannelIn, short[] rightChannelIn, short[] leftChannelOut, short[] rightChannelOut)

    This function implements a low-level sound effect filter that directly changes the sound wave by using various bit operation sub-filters (e.g., Tone Filter, Delay Filter, etc). I wonder if it's possible to use this function to apply this sound effect to all audio outputs from all apps in the device. I found a webpage about class AudioEffect:

    https://developer.android.com/reference/android/media/audiofx/AudioEffect

    But this page seems to describe how to use the Android platform's built-in sound effect APIs, which is not about directly injecting our custom filter logic to manipulate sound bits on the fly (for all audio outputs from all apps).

    Does anyone have any idea on the feasibility of this?

    submitted by /u/EggplantMaleficent13
    [link] [comments]

    Should I use scroll view for each and every screen?

    Posted: 04 May 2022 11:05 AM PDT

    I'm new to Android and I've been having difficulties fitting views into a single screen, up until I found ScrollView. I now find it easier to fit items on the same screen, for different screen sizes. I use ScrollView as the root and nest ConstraintLayout inside it.

    Is it wrong to use ScrollView for each and every screen, is it bad design, considering that I am using ConstraintLayout?

    submitted by /u/guitarhippo
    [link] [comments]

    How do I Compile My Own Android OS from Source for my Samsung A20s 3GB

    Posted: 04 May 2022 06:28 PM PDT

    Hi. After the Android OS updates, I need to make a minor adjustment to my phone. Currently, my Samsung A20s (SM-A207F -- a20sxx) is on Android 11 with only 3GB Ram, as soon as it boots almost all of my RAM is Gone.

    I want to reduce the Java VM Heap Size Which is Currently 192MB, Hoping my Phone can overcome these updates and still function with only 3GB of RAM.

    for example, with everything closed, I only have about 600MB, around 22%

    It's slow and laggy and no software can magically fix this as it's not a software issue.

    I want to compile an Android 11 with Java Heap of 192 MB (current), 128 MB, 96 MB, and 64 MB.

    So we have the Android Source and GPU binaries (to compile against) and pretty much everything we need to do this on a windows 10+ (mine is Pro WorkStation 11) BUT:

    How do I (is there any) custom image for MY version on Android in Samsung's database? and if there is, is it pre-compiled for the changes I need to make (well technically one change)?

    I'm writing this post while searching the net for a SM-A207F (a20sxx) Source and the required steps (the how tos) of changing the Heap size.

    if successful, this will turn into a how to tutorial for others, who want their old phones back!!! 👍

    submitted by /u/kage_heroin
    [link] [comments]

    Frames Lost during initital composition in jetpack compose

    Posted: 04 May 2022 02:37 PM PDT

    This my first post here and I dont know proper format to ask a query.

    I am trying to learn jetpack compose while building a project. I am using a scaffold and when i navigate to a particular screen, i am losing frames as seen in the video. I could not find any resources in google related to this. Been stuck with this problem for days.Thank you for you help in advance !

    I am attaching link to video where frame loss is depicted.

    Link to video

    Link to file if needed

    submitted by /u/lma0o0o00
    [link] [comments]

    Domain Verification for GCP

    Posted: 04 May 2022 02:36 PM PDT

    Hello, not sure if this is the right place to do this but it seems so.

    I have made an mobile app, a platformer game, distributed by Google Play Store. Naturally, I would like to include Google Play Games sign-in. It works all fine and well, but now that I am publishing it, Google Cloud Platform wants me to verify the authorized domains for my OAuth consent screen.

    This is where I am confused. It, of course, needs the application homepage. That domain was purchased through Google Domains and hosted by Google Sites. When I go to the Search Console, it says I am already the verified owner. The account I use for Play, Cloud, and Search Console are all the same, yet I am still being asked to verify it.

    Problem #2 is this <appname>-<clientID>.firebaseapp.com domain that is used by a web client auto created by google. I do not know where this came from, and of course, do not own it.

    What do I do? Can I remove the firebase domain from my web client? What else do I need to do to verify the domain that I own?

    submitted by /u/Michigent202
    [link] [comments]

    Android AR Geolocation SDK open source

    Posted: 04 May 2022 10:14 AM PDT

    Hi everyone, I was looking to create an AR-based application for some demonstration of an idea. But I'm stuck at this SDK thing with geolocation support. I could not find any open source or any SDK with less subscription rate. Please help me find out any example which is easy to implement and has less to pay or is open source so I can start easily.

    I found out ARcore has support with the old code of sceneform plus there is no geo location support and has not many examples out there.

    Lightship is good but again they also don't have the geolocation support.

    I tried Wikitude SDK which is think is great and easy but I found it costly and around 2490 euro which is too costly for me. Please help me with any alternative you are aware of which developers are using these days.

    Thank you

    submitted by /u/vikaskumarrajput
    [link] [comments]

    Best place for Connectivity Check in Clean Architecture

    Posted: 04 May 2022 08:45 AM PDT

    Hi all, I am busy with an architectural refactor of an app to clean architecture (ViewModel -> UseCase -> Repo ...etc).

    I am battling with where to put connectivity checks before a request is made. I assume that it should be in the UI layer since it requires Android's Context class to check connectivity. Maybe in the ViewModels before launching the Coroutine? Would my ViewModels still be unit testable if I do this?

    I've seen examples where Interceptors are added to the OkHttpClient for connectivity checks but this doesn't seem right.

    Any recommendations would be appreciated.

    submitted by /u/LoyTheKing
    [link] [comments]

    How many DPI bucket resource folders do you use?

    Posted: 04 May 2022 11:25 AM PDT

    There's w550dps, w760dps, 1024dps, v22s, and tvdpi, nodpi, l, m, h, xh, xxh, and xxxh for all of them.

    My understanding is that the advantage is mostly lowing APK size for lower devices with smaller resources. Feels like view and presentation sizing should be based on dynamic values rather than relying on the size of an asset.

    submitted by /u/thermosiphon420
    [link] [comments]

    Google rolled out Android 12 QPR3 Beta 3 update

    Posted: 04 May 2022 10:53 AM PDT

    ListAdapter with Header

    Posted: 04 May 2022 09:07 AM PDT

    I am currently using this approach for now to have my Filterable ListAdapter support header itemview.

    Unfortunately sometimes when launching the app I am getting this error

    Cannot call this method while RecyclerView is computing a layout or scrolling

    when calling submitList() and the error starts at notifyItemRangeInserted inside onInserted

    I really can't reproduce this and only encounter it twice. Does anyone have a better approach of implementing header itemview in ListAdapter?

    submitted by /u/Interesting_Music464
    [link] [comments]

    Looking for a hint

    Posted: 04 May 2022 08:37 AM PDT

    Hi,

    I'd like to have an app, where you can swipe between fragments, to display different piece of api response. To visualise it more, I'll give you an example:

    We have an forecast app - whenever user open the app, the current forecast are being displayed, whenever the user swipe left, then the fragment are beeing changed, and user will see let's say hourly forecast, and if he'll swipe right - daily forecast.

    Now, I struggling with understand how can I apply that scenario into the android studio. For now, I'm using the FragmentsAdapter, and I believe it work similar to the RecyclerView one. I kinda don't understand, how I can implement there logic to display the information that I've meantioned above.

    Should I just extend this adapter with some ViewHolder, and then initiate all of the views inside of it? As we are implemeting logic in the onCreateViewHolder method, while creating a View, and inflating it by given layout, should I just add something like "fragment number" and accroding to the given by fragment number, inflate specified inside if layout?

    submitted by /u/BackToDream
    [link] [comments]

    No comments:

    Post a Comment