Environment
- flutter_poolakey: ^2.2.0+1.0.0
- Android targetSdkVersion: 34,35 (Android 14 and 15)
- Tested devices: Samsung / Xiaomi / Pixel (Android 14 and 15)
- Bazaar version: 11.12.0+
After updating the app to targetSdkVersion 34 or running on Android 14 / 15, the in-app billing connection using FlutterPoolakey.connect() fails unless the Bazaar app is already running in the background.
This means that the system denies the bindService call because Bazaar’s process is killed or in background state.
According to Google’s official Android 14 behavior changes, apps must now opt-in to allow background service binding by including the flag BIND_ALLOW_ACTIVITY_STARTS:
“When a visible app binds a service of another app that's in the background using the bindService() method, the visible app must now opt in ... include the BIND_ALLOW_ACTIVITY_STARTS flag.”
(https://developer.android.com/about/versions/14/behavior-changes-14)
Expected behavior
FlutterPoolakey.connect() should automatically handle the new Android 14+ requirement and use BIND_ALLOW_ACTIVITY_STARTS when calling bindService, so that the Bazaar billing service can be bound even when Bazaar is not running.
Actual behavior
Binding fails with PowerController.BgClean until the user manually opens the Bazaar app, which makes the process alive again.
Steps to reproduce
- Close Bazaar completely (force stop).
- Launch the Flutter app built with targetSdkVersion 34.
- Call
FlutterPoolakey.connect().
- Observe logcat:
PowerController.BgClean: deny bind-service.
Suggested fix
In the native Android layer of Poolakey, update the service binding call:
context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE or Context.BIND_ALLOW_ACTIVITY_STARTS)
https://developer.android.com/about/versions/14/behavior-changes-14
محیط اجرا
• نسخه پکیج: flutter_poolakey: ^2.2.0+1.0.0
• نسخه هدف اندروید: targetSdkVersion برابر با 34 و 35 (Android 14 و 15)
• دستگاههای تستشده: Samsung / Xiaomi / Pixel (با Android 14 و 15)
• نسخه بازار: 11.12.0+
⸻
بعد از بهروزرسانی اپ به targetSdk 34 یا اجرا روی Android 14 و 15، اتصال پرداخت درونبرنامهای از طریق FlutterPoolakey.connect() تنها زمانی برقرار میشود که اپ بازار از قبل در پسزمینه در حال اجرا باشد.
این به آن معناست که سیستم اندروید اجازهٔ فراخوانی bindService را نمیدهد، چون process بازار در حالت background یا متوقفشده است.
طبق مستند رسمی گوگل در مورد تغییرات رفتاری Android 14، اپها باید بهصورت صریح (opt-in) اجازه دهند که سرویسهای خارجی در حالت background بتوانند Activity باز کنند؛ برای این کار باید در زمان فراخوانی bindService فلگ جدید BIND_ALLOW_ACTIVITY_STARTS را اضافه کنند.
«وقتی یک اپ قابلمشاهده (visible app) به سرویس اپ دیگری که در پسزمینه است با متد bindService متصل میشود، باید صریحاً اجازه دهد که آن سرویس از privilege اجرای Activity در پسزمینه استفاده کند. برای این کار باید فلگ BIND_ALLOW_ACTIVITY_STARTS در bindService تنظیم شود.»
[مستند رسمی گوگل](https://developer.android.com/about/versions/14/behavior-changes-14)
⸻
رفتار مورد انتظار
تابع FlutterPoolakey.connect() باید بهصورت خودکار این تغییر Android 14+ را مدیریت کند و در فراخوانی bindService از فلگ BIND_ALLOW_ACTIVITY_STARTS استفاده کند تا اتصال به سرویس پرداخت بازار حتی در حالتی که بازار در پسزمینه نیست نیز برقرار شود.
⸻
رفتار فعلی
اتصال (bindService) با خطای PowerController.BgClean شکست میخورد تا زمانی که کاربر اپ بازار را بهصورت دستی باز کند و process آن دوباره فعال شود.
⸻
مراحل بازتولید
1. اپ بازار را کاملاً ببند (Force Stop).
2. اپ Flutter را با targetSdkVersion 34 اجرا کن.
3. متد FlutterPoolakey.connect() را صدا بزن.
4. در logcat مشاهده میشود:
PowerController.BgClean: deny bind-service
⸻
پیشنهاد برای رفع مشکل
در لایهٔ native اندروید مربوط به Poolakey، هنگام فراخوانی bindService باید فلگ جدید اضافه شود:
context.bindService(
intent,
serviceConnection,
Context.BIND_AUTO_CREATE or Context.BIND_ALLOW_ACTIVITY_STARTS
)
با این تغییر، Poolakey با سیاستهای جدید Android 14 و Android 15 هماهنگ خواهد شد و اتصال به سرویس پرداخت بازار بدون نیاز به باز بودن خود اپ بازار انجام میشود.
Environment
After updating the app to targetSdkVersion 34 or running on Android 14 / 15, the in-app billing connection using
FlutterPoolakey.connect()fails unless the Bazaar app is already running in the background.This means that the system denies the bindService call because Bazaar’s process is killed or in background state.
According to Google’s official Android 14 behavior changes, apps must now opt-in to allow background service binding by including the flag
BIND_ALLOW_ACTIVITY_STARTS:(https://developer.android.com/about/versions/14/behavior-changes-14)
Expected behavior
FlutterPoolakey.connect()should automatically handle the new Android 14+ requirement and useBIND_ALLOW_ACTIVITY_STARTSwhen callingbindService, so that the Bazaar billing service can be bound even when Bazaar is not running.Actual behavior
Binding fails with
PowerController.BgCleanuntil the user manually opens the Bazaar app, which makes the process alive again.Steps to reproduce
FlutterPoolakey.connect().PowerController.BgClean: deny bind-service.Suggested fix
In the native Android layer of Poolakey, update the service binding call: