<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Serhii Tereshchenko on Medium]]></title>
        <description><![CDATA[Stories by Serhii Tereshchenko on Medium]]></description>
        <link>https://medium.com/@serhii-tereshchenko?source=rss-93cd02340ca8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*feHj-bQlWQ17AbuggaDQ-w@2x.jpeg</url>
            <title>Stories by Serhii Tereshchenko on Medium</title>
            <link>https://medium.com/@serhii-tereshchenko?source=rss-93cd02340ca8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 17:36:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@serhii-tereshchenko/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How Uber Almost Stole £13 From Me or Why Automation in Customer Support Kills User Trust]]></title>
            <link>https://medium.com/@serhii-tereshchenko/how-uber-almost-stole-13-from-me-or-why-automation-in-customer-support-kills-user-trust-a06ba1ed3886?source=rss-93cd02340ca8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a06ba1ed3886</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[customer-experience]]></category>
            <dc:creator><![CDATA[Serhii Tereshchenko]]></dc:creator>
            <pubDate>Mon, 17 Aug 2026 17:14:21 GMT</pubDate>
            <atom:updated>2026-08-17T17:34:09.845Z</atom:updated>
            <content:encoded><![CDATA[<h3>Personal background</h3><p>After spending four and a half wonderful years in a small yet high-tech country called Estonia at Bolt, I made the big life decision to relocate to the UK. I knew it was a big investment in my career as a Senior Software Engineer. Juggling the demands of a new role while moving my entire family, I heavily relied on ride hailing services like Bolt and Uber. But what could go wrong with something as routine as ordering a taxi?</p><p>Spoiler: everything.</p><h3>£13 for a 1-Minute Ride I Never Took</h3><p>At some point, I ended up in a pretty common situation: my driver accepted the ride and cancelled it after 30 seconds, charging me £13 for ride that didn’t happen. I didn’t pay much attention at first, assuming it would take seconds to claim my money back in the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pcLJ4X9z2umn8HyOQdRR2g.png" /></figure><p>When I submitted a refund request, it was rejected. The system marked the ride as completed and charged the minimum fare for a 30-second trip in the middle of London. Every time I tried to reopen the ticket, I was rerdirected back to the automated refusal, with zero option to speak with a person.</p><p>The only workaround I’ve found was to make a phone call, that took around 30 minutes. It was a horrible customer experience. But as someone who previously worked in this industry and someone, who really cares about end-user quality of product, I want to share my thoughts on why this approach is destructive and short-sighted for business.</p><h3>When AI Blocks the Door</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LbVAP4cY1DZgQf-pPVkVZg.png" /></figure><p>Automated agents should serve as a first line of contact, and they play a key role in saving valuable time for human support teams. But the main requirement is that there must always be a seamless escalation path, giving users the option to reach a real person when automation fails to help. I strongly believe, that in the nearest 5-10 years, customer support will become a key factor that defines a company’s reputation.</p><p>On paper and in the PM dashboard, the system looks like a massive success:</p><ul><li><strong>Amount of tickets is dropping:</strong> fewer tickets reach expensive human agents.</li><li><strong>Support overhead is down:</strong> operational costs drop significantly.</li><li><strong>Refund payouts decrease:</strong> margin protection looks great on reports.</li></ul><p>But from the user’s perspective? You’ve just hit a digital wall. You feel robbed, and unfairly rejected by an algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*5pPLwGjfCuIggaoIh8AXYw.gif" /></figure><h3>An Engineer’s Point of View: Why it Failed</h3><p>As a software engineer, I can see the root of problem. The issue wasn’t the AI model itself . It was the total lack of context awareness.</p><p>Here is where the system fundamentally failed:</p><ul><li><strong>Blind Trust in Isolated Data Points:</strong> Instead of evaluating trip duration (under 60 seconds), GPS trajectory (zero distance moved), or traffic conditions in central London, the logic made a binary decision based on a high-level status flag.</li><li><strong>Absence of Confidence Thresholds:</strong> Good automation relies on confidence scoring. A 30-second trip charged at £13 is an obvious anomaly. When confidence is low, the system should automatically route the issue to human review rather than rejecting the user with unearned certainty.</li><li><strong>AI as a Wall Instead of a Tool:</strong> The biggest mistake was treating the AI agent as a fortress with the absolute power to close tickets permanently. Automation should gather context and pre-fill data so human agents can resolve issues in seconds . Not act as a gatekeeper that locks users out of help.</li></ul><h3>The Real Cost of “Optimized” Customer Support</h3><p>Most people won’t spend 30 minutes on the phone to fight for £13. They have jobs, kids, and busy lives. They will just give up, close the app, and accept the loss. Companies spend millions running marketing campaigns to acquire new users and keep them in the ecosystem. As an engineer who relies on taxi services daily in London, my annual spend on these platforms easily reaches thousands of pounds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GRatN3-kE785gwFXCqsssQ.jpeg" /></figure><p>By “saving” £13 on a broken automated dispute, the platform didn’t win anything. Instead, they damaged brand reputation. A frustrated customer doesn’t just stay quiet. They tell their colleagues, share it online, and write articles like this one.</p><h3>How to Build AI Support Right</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*87XZymp14hHLCWTel9OfeA.jpeg" /></figure><p>AI agents brings incredible value when designed with empathy and robust architecture. If you are building automated support workflows today, here is what you should keep in mind:</p><ul><li><strong>Always Build an “Escape Hatch”:</strong> Never trap users in a dead end. If the automated response fails to resolve the issue, a single click should allow the user to escalate the ticket to a human agent directly within the app without forcing them through external hurdles or phone queues.</li><li><strong>Treat Anomalies as Escalations:</strong> Train your AI agent to spot edge cases. When trip duration is absurdly short, GPS coordinates barely move, the model should flag the ticket for manual review rather than making confident, flawed decisions.</li><li><strong>Align KPIs with Retention, Not Just Deflection:</strong> If your primary metric is “how many tickets the bot deflected,” you are optimizing for nothing. Measure <strong>Customer Effort Score (CES)</strong> and long-term retention alongside resolution speed.</li></ul><h3>Happy End</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o7YMmJ9-ZYIFWbhx3OHhzQ.jpeg" /></figure><p>Getting my money back felt like a small win, but it left a one question in my head: why did it take a 30-minute phone call, an extra authentication loop, and unnecessary friction to fix an obvious mistake that a human could resolve in under ten seconds?</p><p>Technology is meant to remove friction from our lives, not build a wall between companies and customers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a06ba1ed3886" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Android Widgets: A Practical Guide]]></title>
            <link>https://medium.com/@serhii-tereshchenko/implementing-android-widgets-a-practical-guide-396b28325b9a?source=rss-93cd02340ca8------2</link>
            <guid isPermaLink="false">https://medium.com/p/396b28325b9a</guid>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[widget]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Serhii Tereshchenko]]></dc:creator>
            <pubDate>Sat, 31 May 2025 12:36:07 GMT</pubDate>
            <atom:updated>2025-06-01T12:16:20.145Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kMRMw-WHmntdzjUJVx77Tg.png" /></figure><h3>1. Introduction</h3><p>Widgets are an important part of the user experience. Being a UI element, that is always visible on your home screen, they may significantly boost user engagement, providing users an important information from your application and serving as a shortcut to deeper functionality.</p><p>When I tried to implement my first widget, I faced a lack of information. First things first, I went to the <a href="https://developer.android.com/develop/ui/views/appwidgets">Android Developers website</a> to read the documentation — but it felt too dry for me.</p><p>In this article, I’ll share practical insights that I gained while building a <strong>real widget</strong> for a <strong>production app</strong>. I’ll also share some practical advice (see the “<strong><em>Good to know!💡</em></strong>” sections) that would’ve saved me hours if I had known it earlier.</p><h3>2. Planning Your Widget</h3><p>Widget provides glanceable information or a quick shortcut to an action. Here are some of the key aspects I considered before implementation:</p><ul><li><strong>Update Frequency:</strong><br>Decide how often the widget should update. Is the content static until a user action? Does it need to refresh every hour or day? Find an optimal update time window, but don’t act like a bad citizen — frequent updates can drain battery and may be throttled by the system.</li><li><strong>Edge Cases:</strong><br>Think through the lifecycle. What happens if the user cleans app data? What if the widget was added but user hasn’t opened the app yet (no data to show)? Don’t assume the widget always has access to fresh content. Provide meaningful fallback UI (like a message or placeholder), so the widget doesn’t look broken.</li><li><strong>Permissions Awareness:</strong><br>If your widget needs location or account data, ensure your app has the proper permissions. The widget won’t be able to request them directly. Instead, handle the request flow when the user launches your app from the widget.</li></ul><h3>3. Creating UI for widget</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhMYeEYH7mEYaO7YioqvuA.png" /></figure><p>Designing the layout for a widget is a way different from designing a typical app screen.</p><ul><li><strong>Resizing and Layout Flexibility:</strong><br>If your widget supports resizing (resizeMode=&quot;horizontal|vertical&quot;), make sure the layout adjusts accordingly. Use weights or wrap_content carefully, and always test small and large grid sizes to avoid awkward gaps or clipped content.</li><li><strong>Preview UI (Important but often missed):</strong><br>Make sure the widget preview in the launcher looks realistic. A blank or misleading preview lowers the chance user will add the widget.</li></ul><h4>🚧 Widget Limitations</h4><ul><li><strong>RemoteViews doesn’t support limited amount of views</strong>:<br>You can’t use just any layout or view. For example, ConstraintLayout, RecyclerView, and ViewPager are <strong>not supported</strong>. Stick to safe layouts like LinearLayout, FrameLayout, and basic views like TextView, ImageView, and Button. You may check a list of supported views in <a href="https://developer.android.com/reference/android/widget/RemoteViews">RemoteViews documentation</a>.</li><li><strong>No Animation Support</strong>:<br>RemoteViews doesn’t support animations like ObjectAnimator or ViewPropertyAnimator. If you want timed updates (like changing text every few seconds), you can simulate it using a Handler + postDelayed() or set up timed updates via background workers. But honestly — since widgets aren’t designed for animations, I strongly advise against using dynamic content here. It’s better to keep it static and predictable.</li><li><strong>Gestures Are Limited</strong>:<br>There’s no support for swipe gestures or long press actions. Even multiple tap zones need to be defined manually — you can’t just handle them like you would in an Activity or Fragment.</li></ul><blockquote><strong>Good to know!💡 </strong>Always try to stretch your content to container. The system may allocate more cell space than your layout uses, and if your widget doesn’t expand to fill it, you’ll end up with awkward empty gaps. Use match_parent where possible and test on various grid sizes.</blockquote><h3>4. Implementing the AppWidgetProvider</h3><p>The heart of any Android widget is the AppWidgetProvider. In Android ecosystem it’s a broadcast receiver that listens for widget-related events like creation, updates, and removal.</p><p>You typically override these key callbacks:</p><ul><li>onUpdate() — called when the widget needs to be updated (usually by timer or when widget instance is added)</li><li>onEnabled() — called when the first widget is added to the home screen.</li><li>onDisabled() — called when the last widget instance is removed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uqz2G1GTknAt1fXqQoUFjA.png" /></figure><p>We decided not to rely on updatePeriodMillis in the widget’s XML (which only supports 30+ minute intervals) and instead use WorkManager to handle periodic updates more flexibly.</p><pre>class HomeWidgetProvider : AppWidgetProvider() {<br><br>    private val scope = BaseScope(tag = &quot;HomeWidgetProvider&quot;)<br><br>    override fun onUpdate(context: Context?, appWidgetManager: AppWidgetManager?, appWidgetIds: IntArray) {<br>        // Trigger a one-time update immediately<br>        scope.launch { homeWidgetUpdater.update() }<br><br>        // Schedule periodic background updates<br>        val periodicWorkRequest = HomeWidgetWorker.createPeriodicRequest()<br>        workManager.enqueueUniquePeriodicWork(<br>            WIDGET_WORK_NAME,<br>            ExistingPeriodicWorkPolicy.KEEP,<br>            periodicWorkRequest<br>        )<br>    }<br><br>    override fun onDisabled(context: Context?) {<br>        // Cancel background work when no widgets remain<br>        scope.cancel()<br>        workManager.cancelUniqueWork(WIDGET_WORK_NAME)<br>    }<br><br>    companion object {<br>        const val WIDGET_WORK_NAME = &quot;widget_work&quot;<br>    }<br>}</pre><blockquote><strong>Good to know!💡 </strong>If you setupdatePeriodMillis in your XML, its’ minimum value is 30 minutes. WorkManager gives you more control, providing a <strong>minimum interval</strong> for PeriodicWorkRequest is 15 minutes.</blockquote><h4>Widget Configuration (appwidget-provider XML)</h4><p>Every widget needs a config XML that tells the system how it should behave on the home screen. This file lives in res/xml/ and is referenced in your AndroidManifest.xml. Here’s what I used in my project:</p><pre>&lt;appwidget-provider xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:description=&quot;@string/home_widget_description&quot;<br>    android:initialLayout=&quot;@layout/home_widget&quot;<br>    android:minWidth=&quot;300dp&quot;<br>    android:minHeight=&quot;80dp&quot;<br>    android:previewLayout=&quot;@layout/home_widget_preview&quot;<br>    android:resizeMode=&quot;none&quot;<br>    android:targetCellWidth=&quot;4&quot;<br>    android:targetCellHeight=&quot;2&quot;<br>    android:updatePeriodMillis=&quot;0&quot;<br>    android:widgetCategory=&quot;home_screen&quot; /&gt;</pre><ul><li><strong>initialLayout</strong> – the layout used when the widget is first placed.</li><li><strong>minWidth / </strong><strong>minHeight</strong> – minimum space the widget needs, in dp</li><li><strong>targetCellWidth / </strong><strong>targetCellHeight</strong> – approximate grid size the widget is optimized for. The default grid size for the home screen on most Android launchers is typically 4x5. However, this can vary depending on the specific Android version and launcher being used.</li><li><strong>previewLayout</strong> – layout shown in the widget picker preview.</li><li><strong>resizeMode=&quot;none&quot;</strong> – disables resizing; set to &quot;horizontal|vertical&quot; to support it.</li><li><strong>updatePeriodMillis=&quot;0&quot;</strong> – disables system-driven periodic updates; we’re using WorkManager instead.</li><li><strong>widgetCategory</strong> – tells the system where this widget can be shown (e.g. home screen, keyguard).</li></ul><blockquote><strong>Good to know!💡 </strong>If your widget appears broken or doesn’t show up in the picker, double-check this config. Also, make sure it’s correctly linked in your AndroidManifest.xml using a &lt;receiver&gt; tag.</blockquote><h3>5. Handling Widget Updates</h3><p>One of the key design decisions you’ll need to make is <strong>how and when your widget should update</strong>. Doing all the logic inside onUpdate() may work for simple widgets, but for more complex logic, it may quickly become a bad idea — especially if you’re doing asynchronous operations (like fetching user data or device location).</p><p>To avoid blocking the UI thread or hitting system restrictions, we used a coroutine-based Worker that runs all the heavy lifting in the background.</p><pre>class HomeWidgetWorker : CoroutineWorker(...) {<br><br>    override suspend fun doWork(): Result {<br>        // Update widget content (e.g., fetch user data, location, or recommendations)<br>        val updated = homeWidgetUpdater.update()<br>        return if (updated) Result.success() else Result.failure()<br>    }<br><br>    companion object {<br>        fun createPeriodicRequest(): PeriodicWorkRequest {<br>            return PeriodicWorkRequestBuilder&lt;HomeWidgetWorker&gt;(15, TimeUnit.MINUTES)<br>                .setInitialDelay(15, TimeUnit.MINUTES)<br>                .build()<br>        }<br>    }<br>}</pre><h4>WorkManager vs updatePeriodMillis</h4><p>There are multiple strategies for updating your widget. Choosing the right one depends on how frequently your data changes and how much control you need over update timing.</p><h4>🕒 updatePeriodMillis</h4><p>The system can send update broadcasts at fixed intervals. This is configured via updatePeriodMillis in the appwidget-provider XML:</p><pre>&lt;appwidget-provider<br>    android:updatePeriodMillis=&quot;1800000&quot; &lt;!-- 30 minutes --&gt;<br>    ... /&gt;</pre><p>But Android enforces a minimum value of 30 minutes, and on newer versions, updates may be throttled even further. This makes static updates <strong>unreliable</strong> if your widget needs to stay fresh in near real-time.</p><blockquote><strong>Good to know!💡 </strong>Some OEMs (like Xiaomi or Samsung) are particularly aggressive about throttling background tasks. You may see fewer updates than expected, even if you set the correct interval.</blockquote><h4>⚙️ WorkManager</h4><p>We wanted full control over our update schedule, so we used WorkManager to handle background updates:</p><ul><li>Supports Constraints, (i.e. battery state or internet connection status)</li><li>Respects system battery optimizations.</li><li>Allows fine-tuned scheduling (every 15 minutes is the minimum for PeriodicWorkRequest).</li></ul><p>This approach is ideal for keeping your widget updated without relying on system broadcasts alone.</p><h4>🚀 Manual Updates from the App</h4><p>If you want to trigger a widget refresh inside app (e.g. after the user completes an action, grants permissions, or changes settings), you can update the widget directly using AppWidgetManager. In our case, we encapsulated all update logic in a single class, HomeWidgetUpdater, and simply call its update() method when needed:</p><pre>// Inside any part of the app (e.g. after location permission granted)<br>lifecycleScope.launch {<br>    homeWidgetUpdater.update()<br>}</pre><p>And here’s a simplified breakdown of what HomeWidgetUpdater.update() does:</p><pre>suspend fun update(): Boolean {<br>    val appWidgetIds = getWidgetIds() ?: return false<br><br>    // Step 1: Build RemoteViews<br>    val remoteViews = RemoteViews(context.packageName, R.layout.home_widget)<br><br>    // Step 2: Set click handling<br>    remoteViews.setOnClickPendingIntent(<br>        R.id.widgetSearchButton,<br>        buildDeeplinkIntent(&quot;myapp://search&quot;)<br>    )<br><br>    // Step 3: Handle UI state (e.g. show message if user not logged in)<br>    if (!isUserLoggedIn()) {<br>        remoteViews.setTextViewText(R.id.widgetMessage, &quot;Please log in&quot;)<br>    } else {<br>        // Display content<br>        remoteViews.setTextViewText(R.id.widgetMessage, &quot;Welcome back!&quot;)<br>    }<br><br>    // Step 4: Apply update<br>    appWidgetIds.forEach {<br>        appWidgetManager.updateAppWidget(it, remoteViews)<br>    }<br><br>    return true<br>}</pre><p>This approach gives you direct control over what your widget displays. It’s also easier to test, especially when the app is already in memory and actively responding to user actions. No need for custom broadcasts, no manual ID passing, and it works instantly.</p><h4>6. Click handling</h4><p>Widgets don’t support direct click listeners like regular views — instead, they rely on PendingIntent. Here’s a basic example of opening an activity when a user taps a widget button:</p><pre>val intent = Intent(context, MainActivity::class.java)<br>val pendingIntent = PendingIntent.getActivity(<br>    context,<br>    0,<br>    intent,<br>    PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT<br>)<br><br>remoteViews.setOnClickPendingIntent(R.id.widget_button, pendingIntent)</pre><blockquote><strong>Good to know!💡 </strong>Click listeners won’t notify you if you use the wrong view ID. RemoteViews won’t throw an error — it’ll just silently ignore the event. Always double-check your IDs and test every interaction path.</blockquote><h3>7. Debugging</h3><p>Designing of widgets requires to think a little bit differently, than you do when you work with application in foreground. Widget state depends on broadcast events, layout constraints, and system limitations. Here are some common pitfalls I ran into — and how to avoid them:</p><ul><li><strong>Log every edge case</strong>:<br>Whether it’s a missing permission, no location, or null data — log it. You’ll thank yourself when debugging real-world issues.</li><li><strong>Avoid overlapping updates</strong>:<br>If you’re scheduling frequent updates via WorkManager or other mechanisms, make sure you’re not stacking multiple requests. In my case widget was reloading to its’ initial state.</li><li><strong>Don’t assume the app is running</strong>:<br>Your widget might get updated when the app is completely killed. Make sure all your logic (data loading, UI state, etc.) is safe to run in isolation.</li></ul><h3>8. Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GWTSiOdV6ZC6wDmO-mnGZg.jpeg" /></figure><p>While widget can be considered as not a vital part of mobile application, it may definitely improve user experience. Make it useful, and responsive. For me, building a home screen widget felt like working with old Android APIs. But the result can significantly enhance user experience and engagement.</p><p>I hope this article was useful and your journey with widgets will be smooth. If you’re building your first widget, don’t overthink it — start small, test a lot, and iterate quickly.</p><p>Happy coding! ✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=396b28325b9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Grokking Google Play Billing API with Kotlin Coroutines]]></title>
            <link>https://medium.com/@serhii-tereshchenko/grokking-google-play-billing-api-with-coroutines-1ac80337021a?source=rss-93cd02340ca8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ac80337021a</guid>
            <category><![CDATA[coroutines-in-kotlin]]></category>
            <category><![CDATA[billing]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[google-play]]></category>
            <dc:creator><![CDATA[Serhii Tereshchenko]]></dc:creator>
            <pubDate>Sun, 16 Feb 2025 18:19:58 GMT</pubDate>
            <atom:updated>2025-02-18T07:25:58.371Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_65AV9lUsBde2cSjUnSPNw.jpeg" /></figure><p>Relying on ads to monetize your app is getting tougher. Selling in-app items may significantly increase your revenue. In this article, we’ll walk through the key concepts and best practices for using <strong>Google Play Billing 7.1</strong> in a real-world app.</p><p>With a practical advices from me (<strong>Good to know!💡</strong>section), we’ll take a closer look at how purchases work — specifically, the process of selling a digital item and making sure users actually receive what they paid for. To keep things simple, we’re focusing only on one-time purchases for now.</p><p>There are two types of one-time purchases:</p><ol><li><strong>Consumable.</strong> Consumable products can be bought more than once. For example, if your app is a game where users can buy coins, you’d make those coins a consumable product so they can keep purchasing them as needed</li><li><strong>Non-consumable.</strong> Non-consumable products, on the other hand, can only be bought once — like a premium upgrade that unlocks extra features.</li></ol><p>Once you’ve set up your in-app products in the Google Play Console, here’s how the purchasing process typically works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*4mLeVF-AQWGViIo7He-GGg.png" /></figure><h3>1. Set up a connection with BillingClient.</h3><p>BillingClient is the main entry point for working with the Google Play Billing Library. To set up a connection, use <a href="https://developer.android.com/reference/com/android/billingclient/api/BillingClient#startconnection">startConnection()</a>. It has two callbacks:</p><pre>/**<br>* Billing client is ready. Query list of purchases here.<br>*/<br>onBillingSetupFinished(billingResult: BillingResult)<br><br>/**<br>* You can&#39;t do operations with BillingClient at this stage.<br>* Be sure to check connection every time before making an operations with BillingClient<br>*/<br>onBillingServiceDisconnected()</pre><p>For this purpose I made a helper class, <em>BillingManager.kt</em> that presents a coroutine way of handling in-app purchases.</p><pre>class BillingManager {<br>    ...<br>    private var billingClient: BillingClient = buildBillingClient()<br><br>    private fun buildBillingClient(): BillingClient {<br>        return BillingClient.newBuilder(context)<br>            .enablePendingPurchases(<br>                PendingPurchasesParams.newBuilder()<br>                    .enableOneTimeProducts()<br>                    .build()<br>            )<br>            .setListener { billingResult, purchases -&gt;<br>                when (billingResult.responseCode) {<br>                    BillingResponseCode.OK -&gt; {<br>                        purchaseFlow.tryEmit(purchases.orEmpty())<br>                    }<br><br>                    BillingResponseCode.USER_CANCELED -&gt; {<br>                        Timber.d(billingResult.debugMessage)<br><br>                    }<br><br>                    else -&gt; {<br>                        Timber.d(billingResult.debugMessage)<br>                    }<br>                }<br>            }.build()<br>    }<br><br>    fun establishConnectionAsync(continuation: Continuation&lt;Unit&gt;? = null) {<br>        billingClient.startConnection(object : BillingClientStateListener {<br>            override fun onBillingSetupFinished(billingResult: BillingResult) {<br>                if (billingResult.responseCode == BillingResponseCode.OK) {<br>                    queryPurchasesAsync(continuation)<br>                }<br>            }<br><br>            override fun onBillingServiceDisconnected() {<br>                // reconnect<br>            }<br>        })<br>    }<br>    ...<br>}</pre><p><strong>Good to know!💡</strong></p><blockquote><em>Since connection isn’t always stable, your app should be prepared to handle it. To ensure it stays connected to Google Play before making any further requests, override the </em>onBillingServiceDisconnected()<em> callback.</em></blockquote><h3>2. Request a list of existing purchases for the user.</h3><p>Use <em>BillingClient.queryPurchasesAsync()</em> to retrieve a list of existing purchases. This is required for getting a list of pending purchases.</p><p><strong>Good to know!💡</strong></p><blockquote><em>Results of </em>queryPurchases()<em> are </em><strong><em>cached locally</em></strong><em> on your device. It means that </em>queryPurchases() <em>won’t return a previously purchases on a new device</em>.</blockquote><blockquote><em>Use </em>queryPurchaseHistoryAsync() <em>in order to get all purchases, that user has ever made</em>.</blockquote><pre>class BillingManager {<br>    ...<br>    private val purchaseFlow = MutableStateFlow&lt;List&lt;Purchase&gt;&gt;(emptyList())<br><br>    private fun queryPurchasesAsync(continuation: Continuation&lt;Unit&gt;? = null) {<br>        val queryPurchasesParams = QueryPurchasesParams.newBuilder()<br>            .setProductType(BillingClient.ProductType.INAPP)<br>            .build()<br><br>        billingClient.queryPurchasesAsync(queryPurchasesParams) { billingResult, purchasesList -&gt;<br>            if (billingResult.responseCode == BillingResponseCode.OK) {<br>                purchaseFlow.tryEmit(purchasesList)<br>            } else {<br>                Timber.e(billingResult.debugMessage)<br>            }<br>        }<br>        continuation?.resume(Unit)<br>    }<br>    ...<br>}</pre><h3>3. Present a list of products to the user.</h3><p>Use <em>queryProductDetailsAsync()</em> to retrieve a list of all available products. Once it’s available, retrieve an info about particular product using its’ id.</p><p><strong>Good to know!💡</strong></p><blockquote><em>I strongly advise loading info about products in advance. Caching this data for a short period of time is a right strategy. Don’t let user wait. This step may drop some of the users, especially ones with a slow internet connection.</em></blockquote><pre>const val PRODUCT_ID_REMOVE_ADS = &quot;remove_ads&quot;<br><br>class PurchaseFragment: Fragment() {<br>    ...<br>    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {<br>        lifecycleScope.launch {<br>            // load all existing products<br>            val allProducts = billingManager.loadAllProducts()<br>            // get the exact product we want by id, that we know<br>            val removeAdsProduct = allProducts.firstOrNull { it.productId == PRODUCT_ID_REMOVE_ADS }<br>            // set data for the product<br>            binding.disableAdPrice.text =<br>                removeAdsProduct?.oneTimePurchaseOfferDetails?.formattedPrice<br>            binding.disableAdsPurchaseButton.setOnClickListener {<br>                // launch billing library flow for purchasing<br>                lifecycleScope.launch {<br>                    try {<br>                        val product = allProducts.firstOrNull { it.productId == productId }<br>                        if (product != null) {<br>                            launchBillingFlow(product)<br>                        }<br>                    } catch (e: Exception) {<br>                        Timber.e(e)<br>                    }<br>                }<br>            }<br>        }<br>    }<br>    ...<br>}</pre><pre>class BillingManager {<br>    ...<br>    suspend fun loadAllProducts(): List&lt;ProductDetails&gt; {<br>    if (!billingClient.isReady) {<br>        billingClient = buildBillingClient()<br>        establishConnection()<br>    }<br><br>    return suspendCoroutine { continuation: Continuation&lt;List&lt;ProductDetails&gt;&gt; -&gt;<br>        val params = QueryProductDetailsParams.newBuilder()<br>            .setProductList(productList)<br>            .build()<br><br>        billingClient.queryProductDetailsAsync(params) { billingResult, productDetailsList -&gt;<br>            if (billingResult.responseCode == BillingResponseCode.OK &amp;&amp; productDetailsList.isNotEmpty()) {<br>                continuation.resume(productDetailsList)<br>            } else {<br>                continuation.resumeWithException(BillingException(&quot;Initialisation error&quot;))<br>            }<br>        }<br>    }<br>    ...<br>}</pre><h3>4. Launch purchase flow for the user.</h3><p>When the user selects product to buy it, your app should lead user to purchase flow. On a successful call to <a href="https://developer.android.com/reference/com/android/billingclient/api/BillingClient#launchbillingflow">launchBillingFlow()</a>, the system displays the Google Play purchase screen.</p><p><strong>Good to know!💡</strong></p><blockquote><em>1. Results of </em>launchBillingFlow()<em> reflects a state of purchase process itself. </em>BillingResponseCode.OK <em>means that purchase screen was launched successfully, but it doesn’t give you information if product was purchased by user or not.</em></blockquote><blockquote><em>2. For getting an information about purchase use </em><a href="https://developer.android.com/reference/com/android/billingclient/api/PurchasesUpdatedListener#onPurchasesUpdated(com.android.billingclient.api.BillingResult,%20java.util.List%3Ccom.android.billingclient.api.Purchase%3E)"><em>onPurchaseUpdated()</em></a><em> (we’ll cover it in the next section)</em></blockquote><pre>class PurchaseFragment: Fragment() {<br>    ...<br>    private suspend fun launchBillingFlow(productDetails: ProductDetails) {<br>        val productDetailsParamsList = listOf(<br>            BillingFlowParams.ProductDetailsParams.newBuilder()<br>                .setProductDetails(productDetails)<br>                .build()<br>        )<br>        val billingFlowParams = BillingFlowParams.newBuilder()<br>            .setProductDetailsParamsList(productDetailsParamsList)<br>            .setIsOfferPersonalized(true)<br>            .build()<br><br>        val billingResult = billingManager.launchBillingFlow(<br>            requireContext(),<br>            billingFlowParams<br>        )<br><br>        when (billingResult.responseCode) {<br>            BillingResponseCode.OK -&gt; {<br>            }<br><br>            BillingResponseCode.ITEM_ALREADY_OWNED -&gt; {<br>            }<br><br>            BillingResponseCode.USER_CANCELED -&gt; {<br>            }<br><br>            else -&gt; {<br>            }<br>        }<br>    }<br>    ...<br>}</pre><pre>class BillingManager {<br>    ...<br>    suspend fun launchBillingFlow(activity: Activity, params: BillingFlowParams): BillingResult {<br>        if (!billingClient.isReady) {<br>            billingClient = buildBillingClient()<br>            establishConnection()<br>        }<br><br>        return billingClient.launchBillingFlow(activity, params)<br>    }<br>    ...<br>}</pre><h3>5. Handle purchase result. Verify and Acknowledge purchase.</h3><p>When a user leaves the Google Play purchase screen — whether by completing the purchase by tapping the “Buy” button or canceling it by pressing “Back” — the onPurchaseUpdated() callback returns the purchase result to your app.</p><p>You can determine if the purchase was successful by checking the BillingResult.responseCode. If responseCode == OK, the purchase was completed successfully. The onPurchaseUpdated() callback provides a list of Purchase objects, which contain details about all purchases made through the app. Each Purchase object includes key attributes such as sku, purchaseToken, and isAcknowledged. By examining these fields, you can determine whether a purchase is new and needs processing or if it has already been handled.</p><p><strong>Good to know!💡</strong></p><blockquote><em>1. After user completes payment flow, the purchase may be in </em>Pending<em> state for a long period of time. Be sure to properly indicate it to the user to avoid uncertainty and refunds as a result. Once purchase is done, make sure, that user gets properly notified about it.</em></blockquote><blockquote><em>2. If your app does not acknowledge a purchase within 72 hours, the user will be refunded and will no longer have access to the original purchase they made.</em></blockquote><pre>class PurchaseFragment: Fragment() {<br>    billingManager.observeConsumablePurchase(PRODUCT_ID_REMOVE_ADS)<br>            .asLiveData()<br>            .observe(this) {<br>                lifecycleScope.launch {<br>                    if (!it.isAcknowledged) {<br>                        billingManager.consumeProduct(it)<br>                    }<br>                }<br>            }<br>}</pre><pre>class BillingManager {<br>    ...<br>    fun observeConsumablePurchase(productId: String): Flow&lt;Purchase&gt; {<br>        return purchaseFlow.mapNotNull { purchasesList -&gt;<br>            purchasesList.find {<br>                it.products.contains(productId)<br>                        &amp;&amp; it.purchaseState == PurchaseState.PURCHASED<br>            }<br>        }<br>    }<br><br>    suspend fun consumeProduct(purchase: Purchase) {<br>        if (!billingClient.isReady) {<br>            billingClient = buildBillingClient()<br>            establishConnection()<br>        }<br><br>        val consumeParams = ConsumeParams.newBuilder()<br>            .setPurchaseToken(purchase.purchaseToken)<br>            .build()<br><br>        suspendCoroutine {<br>            billingClient.consumeAsync(consumeParams) { billingResult, purchaseToken -&gt;<br>                if (billingResult.responseCode == BillingResponseCode.OK) {<br>                    it.resume(purchase)<br>                } else {<br>                    val errorMessage = &quot;&quot; // retrieve message based on code<br>                    it.resumeWithException(BillingException(errorMessage))<br>                }<br>            }<br>        }<br>    }<br>    ...<br>}<br><br>class BillingException(message: String): Exception(message)</pre><h3>6. Grant user a product.</h3><p>With the above steps complete, your app can now grant the user the in-app product they purchased!</p><pre>class PurchaseFragment: Fragment() {<br>    billingManager.observeConsumablePurchase(PRODUCT_ID_REMOVE_ADS)<br>            .asLiveData()<br>            .observe(this) {<br>                lifecycleScope.launch {<br>                    if (!it.isAcknowledged) {<br>                        // consume product<br>                        ...<br>                        adSettingsRepository.setPremiumEnabled(true)<br>                        ...<br>                        // update UI, if required<br>                    }<br>                }<br>            }<br>}</pre><p><strong>Good to know!💡</strong></p><blockquote><em>Make sure, that user gets a positive emotions with a new purchase. Make a fancy UI, that will emphasize the feeling of satisfaction and will motivate user to make a next purchase in your app.</em></blockquote><h3>Conclusion.</h3><p>I hope that sharing my experience on Google Billing API will serve as a useful addition to official documentation. I wish you a big profits from your application and a high day-1 retention.</p><p>Feel free to leave your feedback in the comments. Happy coding! ✨</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JX5vhSzQ6c46Wx71hGsYdw.jpeg" /></figure><h3>Useful links:</h3><ol><li><a href="https://gist.github.com/serhiitereshchenko/4dddc14e099d28d47cef1b80a70a96e2">BillingManager.kt on a GitHub</a></li><li><a href="https://developer.android.com/google/play/billing/integrate">Integrate the Google Play Billing Library into your app</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ac80337021a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What I Wish I Knew a 3 Years Ago: Lessons from Feature Leadership]]></title>
            <link>https://medium.com/@serhii-tereshchenko/what-i-wish-i-knew-a-3-years-ago-lessons-from-feature-leadership-f69e8311b9de?source=rss-93cd02340ca8------2</link>
            <guid isPermaLink="false">https://medium.com/p/f69e8311b9de</guid>
            <category><![CDATA[management]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[development-process]]></category>
            <dc:creator><![CDATA[Serhii Tereshchenko]]></dc:creator>
            <pubDate>Sun, 20 Oct 2024 14:47:14 GMT</pubDate>
            <atom:updated>2025-04-24T17:39:23.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*0KkB_jD_kthxPAm9EDMpDg.png" /></figure><p>When I first tried feature leadership in Bolt, I had a lot of misconceptions. Some moments weren’t obvious to me until I learned them the hard way. Looking back, everything could have gone much smoother. Here’s the list of things I wish I knew in advance before stepping in into the feature leadership role.</p><p><strong>1. Assign people directly. </strong><br>There isn’t such a thing as a shared responsibility. Don’t expect from people to be responsible for something unless it’s stated directly. People may mistakenly think that it’s somebody else’s responsibility.</p><p><strong>2. Get commitment from all parties (stakeholders)</strong></p><p>Without a properly organized communication between teams there is no chance you get your feature delivered in time. Be sure to get approval of design document from all teams, who take a part in development. It will help to keep everyone in focus. It can also serve as a great argument in future discussion, that most probably will get raised, once implementation phase is started.</p><p><strong>3. Keep in mind that most people don’t read documents (really, they don’t).</strong><br>As much as we love our design documents, the reality is that most people don’t read them. Set up meetings where you’d walk through the document together. Such sessions allowe people to ask questions and clear up uncertainties. They also ensure everyone is on the same page before the first line of code gets commited.</p><p><strong>4. Define success and failure metrics as early as you can.</strong><br>Define success and failure metrics first before diving into the design document. By doing this, I suddenly realized that instead of diving into solutions, I was more concerned about asking myself, “What do we want to achieve?”. Knowing the goal upfront helped keep this team focused on measurable outcomes, not on finishing tasks in general.</p><p><strong>5. Avoid seagull management. Be constantly involved.</strong><br>Seagull management involves flying in, telling everybody how terrible everything is, trying to solve issues in a moment, and then flying out. That form of management leads to frustration. I found it way more effective to stay involved continuously throughout the feature’s lifecycle — not to micromanage, but to be involved enough to know the potential problems early on and support where they may block development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*HxLp9r9mmAmbPZJgQM1dVQ.jpeg" /></figure><p><strong>6. Set up regular syncs. </strong><br>Another important lesson I learned is that regular syncs are important. Without regular syncups, it’s easy to lose focus on the feature for developers. They don’t need to be long or intense. A quick check-in to align progress and next steps can do wonders for keeping the team focused and motivated.</p><p><strong>7. Dive into the details of the implementation.</strong><br>Don’t be afraid to geek out on the implementation details, even if it seems overkill. I made the mistake of staying too high-level early on, trusting that the engineers were covering everything. But sometimes engineers will skip details they don’t think are important to mention, even though they can make or break a feature. By being eager to learn and getting into specifics, you might catch issues or opportunities that otherwise wouldn’t come up.</p><p><strong>8. Failure is a part of the process.</strong><br>And lastly, do not be afraid to fail. The most valuable lessons I’ve ever learned came from my own failures. It’s easy to feel like a failure push you back, but in reality, it pushes you forward faster than success ever will. The more you fail, the better you become.</p><p><strong>Final Thoughts:</strong><br>There are no final thoughts. I’ll return to this section in the next year. Wish me a good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f69e8311b9de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[7 Essential Steps for Integrating a UI Kit into Your Mobile Application]]></title>
            <link>https://medium.com/@serhii-tereshchenko/7-essential-steps-for-integrating-a-ui-kit-into-your-mobile-application-3f9de78a9b5f?source=rss-93cd02340ca8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f9de78a9b5f</guid>
            <category><![CDATA[management]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[advice-and-opinion]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Serhii Tereshchenko]]></dc:creator>
            <pubDate>Sun, 28 Apr 2024 13:15:53 GMT</pubDate>
            <atom:updated>2024-04-28T13:23:22.136Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6k7HSiAvu3savItRzCvw4g.jpeg" /></figure><p>Integrating a UI Kit into your mobile application can streamline development, enhance user experience, and ensure consistency across your app’s interface. However, this process requires careful planning and coordination. Here are seven steps to guide you through the integration process:</p><h3>1. Conduct a Thorough Investigation</h3><p>Before diving deeply into the integration process, spend additional effort to understand the current state of your application’s design and codebase. Identify all the pain points, inconsistencies, or areas for improvement that a UI Kit could address.</p><h3>2. Collaborate with Your Project Manager (PM)</h3><p>Sync up with your project manager to determine the key benefits of incorporating a UI Kit into your project. Discuss how it aligns with project goals, timelines, and budget constraints. Understanding the strategic value will help you to get comprehensive support from stakeholders.</p><h3>3. Engage with Stakeholders: Communication is key</h3><p>Engage with all parties involved in the project, including designers and developers. Understand their specific needs, preferences, and concerns regarding the integration of the UI Kit.</p><h3>4. Research and Approve Tooling</h3><p>Explore the various UI Kits and tooling options available. Consider factors such as compatibility with your existing tech stack, ease of integration, customization capabilities, and licensing. Once you’ve identified the most suitable tools, seek approval from your company to proceed.</p><h3>5. Maintain Proactive Communication</h3><p>Keep all stakeholders informed and involved throughout the integration process. Share regular updates on your progress, challenges encountered, and milestones achieved. Proactive communication fosters transparency and ensures everyone is on the same page.</p><h3>6. Define Milestones</h3><p>Break down the integration process into manageable milestones. Define clear objectives and timelines for each stage of the initiative. This helps maintain focus, track progress, and celebrate achievements along the way.</p><h3>7. Take Incremental Steps</h3><p>Avoid overwhelming yourself and your team by trying to tackle everything at once. Start with small, manageable steps and gradually build upon them. Focus on implementing key components of the UI Kit that will deliver immediate value to your application.</p><h3>Conclusion:</h3><p>By following these seven steps, you can successfully integrate a UI Kit into your mobile application, improving efficiency, consistency, and user satisfaction.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f9de78a9b5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>