From f053001dc1a3eedb81c5baf984fd40aa1f01d0eb Mon Sep 17 00:00:00 2001 From: coolboy0961 Date: Tue, 13 Jul 2021 03:35:26 +0900 Subject: [PATCH] feat(android): provide ability to get registered broadCastReceiver (#9467) --- packages/core/application/index.android.ts | 4 ++++ packages/core/application/index.d.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/core/application/index.android.ts b/packages/core/application/index.android.ts index 5529bcfc5..b9ea5c926 100644 --- a/packages/core/application/index.android.ts +++ b/packages/core/application/index.android.ts @@ -111,6 +111,10 @@ export class AndroidApplication extends Observable implements AndroidApplication this._systemAppearance = value; } + public getRegisteredBroadcastReceiver(intentFilter: string): android.content.BroadcastReceiver | undefined { + return this._registeredReceivers[intentFilter]; + } + public registerBroadcastReceiver(intentFilter: string, onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void): void { ensureBroadCastReceiverClass(); const registerFunc = (context: android.content.Context) => { diff --git a/packages/core/application/index.d.ts b/packages/core/application/index.d.ts index f95a9c477..5eeb70fc1 100644 --- a/packages/core/application/index.d.ts +++ b/packages/core/application/index.d.ts @@ -628,6 +628,12 @@ export class AndroidApplication extends Observable { */ public static activityRequestPermissionsEvent: string; + /** + * Get a registered BroadcastReceiver, then you can get the result code of BroadcastReceiver in onReceiveCallback method. + * @param intentFilter A string containing the intent filter. + */ + public getRegisteredBroadcastReceiver(intentFilter: string): android.content.BroadcastReceiver | undefined; + /** * Register a BroadcastReceiver to be run in the main activity thread. The receiver will be called with any broadcast Intent that matches filter, in the main application thread. * For more information, please visit 'http://developer.android.com/reference/android/content/Context.html#registerReceiver%28android.content.BroadcastReceiver,%20android.content.IntentFilter%29'