Android Tutorial Adaptive Icons

Discussion in 'Tutorials & Examples' started by Erel, Jul 18, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Starting from Android 8 apps should include an adaptive icon. Without it the icon will appear as a small icon inside the larger template:

    [​IMG]

    (B4A designer still uses an older targetSdkVersion so it is not affected.)

    Adaptive icons are explained here: https://medium.com/google-design/designing-adaptive-icons-515af294c783

    The steps required are:

    1. Create a folder under Objects\res named mipmap. It should include three files:

    [​IMG]

    The two adaptive icon layers and a file named ic_launcher.png with the old icon. The old icon will be used on Android 7- devices.

    2. Make sure that all three files are read-only. Otherwise they will be deleted during compilation.

    3. Add to the manifest editor:

    Code:
    SetApplicationAttribute(android:icon, "@mipmap/ic_launcher")
    CreateResource(mipmap-anydpi-v26, ic_launcher.xml,
    <adaptive-icon xmlns:android=
    "http://schemas.android.com/apk/res/android">
        <background android:drawable=
    "@mipmap/background"/>
        <foreground android:drawable=
    "@mipmap/foreground"/>
    </adaptive-icon>
    )
    4. Delete this line from the manifest editor:
    Code:
    SetApplicationAttribute(android:icon, "@drawable/icon"'delete
     
    Beja, Ohanian, Johan Hormaza and 10 others like this.
  2. Mahares

    Mahares Well Known Member Licensed User

    I do not know about you guys, but this is really one more annoying thing to worry about courtesy Google again. 'If it ain't broke , don't fix it' does not apply to Google.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

  4. Peter Simpson

    Peter Simpson Expert Licensed User

    Adaptive icons explained (Main information is in first 65 seconds)
     
    Last edited: Jul 19, 2018
    fredo, Erel, DonManfred and 1 other person like this.
  5. derez

    derez Expert Licensed User

    Not working for me (b4a 7.3)
     
  6. DonManfred

    DonManfred Expert Licensed User

    You are running it on which android Version (Device)?
    Are the files set to readonly? Means; check if they are still there (if not set to readonly they are removed at compilation).
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    You should also make sure that the referenced android.jar (Tools - Configure Paths) is from platform v27+.
     
  8. wimpie3

    wimpie3 Well-Known Member Licensed User

    Any idea on the recommended sizes in pixels for those three files? The YouTube clip talks about DP, not pixels.
     
  9. derez

    derez Expert Licensed User

    Device is Pixel (8) and the files are read-only.
    It was on android 25. I'll check with 27.
     
  10. derez

    derez Expert Licensed User

    Still not working, it looks for the standard drawable:
    If I put back the deleted line from the manifest - it works but with the previous icon.
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    @derez please start a new thread for this in the questions forum. It is best if you upload a small project with only the icons.
     
  12. eps

    eps Well-Known Member Licensed User

    I couldn't get this working initially, but have now finally been able to set up an Adaptive icon. It was painful!

    I had to remove lots of old android sdk installations which I wasn't referencing but somehow were playing havoc with this part of creating Android Apps. Everything else was working as expected and I had no other problems - just thought I'd share this info. with others just in case they were feeling it wasn't working but should. I used the example app to work out that it should perform as expected but wasn't doing so. Cheers :)
     
  13. RichardN

    RichardN Active Member Licensed User

    My lead Android development device a Samsung S9+ has just updated to the latest Oreo version. There was previously a dialogue accessible from Home Screen > Home Screen Settings > Change Icon Shape. It now appears to have been removed completely. I agree with others in saying this is a retrograde step.

    Previously:
    [​IMG]
     
    Last edited: Feb 11, 2019
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice