Floating-Bubble-View: Unable to pass parameters to `setupBubble()`/`setupNotificationBuilder()` from `onStartCommand()`

Hello Dear,

I was using version 0.5.0 and everything was working fine, but I wanted to upgrade to the latest version (v0.5.1) to have the new updates, unfortunlly, my class which implements the FloatingBubbleService() has an override for onStartCommand() method, once I upgraded the dependency, this overridden method stopped working, it is not called at all.

NOTE: I have made sure that I am registering the service in the <application> tag in the Manifest file and starting the service with an intent.

Also I would like to mention that I am using this method to initialize a lateinit variable that holds a value passed from the intent that starts the service to be used inside setupBubble() method, so if you have a better way to do that please suggest.

I would be glad if you could help me with this issue 🙏🏻

Thanks in Advance 🙏🏻❤

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 20 (11 by maintainers)

Most upvoted comments

Thank you so much for the clarification 🙏🏻❤️

No, it’s not required. In Android 12 and earlier versions, the system automatically granted apps the ability to post notifications. However, in Android 13, the system no longer automatically grants this permission. That’s why POST_NOTIFICATIONS come in. You only need to request this permission in android 13+ if you want to show the notification.

You can find more info here: Android Service. Thank you.

Maybe I have to revamp setupNotificationBuilder() soon.

Thank you!

I’m confused now 😅. Please take a quick look at Sample (line 41 -> 60)

Is your code somthing similar to this?


    override fun initialRoute(): Route {
        return Route.Empty
    }

    private var size = 0

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {

        val _size = intent?.getIntExtra("size", 0)  // assume that _size = 60

        size = _size ?: 0

        showBubbles()          // At this point, the bubble's size parameter = 60

        return START_STICKY
    }
    ...

Great ❤

Thank you so much @TorryDo for caring 🙏🏻❤

Waiting for the next release Insha’Allah 💪🏻❤

Looks like a bug!.

After a short investigation, I found out that it’s hard to pass bubble parameters via onStartCommand() to setupBubble(). This is a silly bug that can be fixed in a blink of an eye. For now, please stay with v0.5.0 and I’ll fix this issue in the next version.

Thank you for pointing it out 💖.

Hi @moazelsawaf,

In v0.5.1, I removed showBubbles() from onStartCommand() (which I should have done a long time ago) and moved it to the onCreate() method.

The reason for that is, if you pass the intent to the service multiple times throughout the service lifecycle, you must override the onStartCommand() method first. Otherwise, the bubble will appear overlapped each time you send the intent.

Therefore, in this version, onStartCommand() is not being touched, and it should behave normally. The reason why the overridden method is not working may be something else.

EDIT: The reason is onStartCommand() initializes the lateinit variables correctly, but the setupBubble() method is called before that occurs, resulting in the bubble displaying old or uninitialized data.

Thank you!