Skip to content

Instantly share code, notes, and snippets.

@DelphiWorlds
Created December 30, 2019 07:17
Show Gist options
  • Save DelphiWorlds/8eaa900ea9df70df902bee2123a64c6d to your computer and use it in GitHub Desktop.
Save DelphiWorlds/8eaa900ea9df70df902bee2123a64c6d to your computer and use it in GitHub Desktop.
uses
Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Os, Androidapi.JNI.JavaTypes, Androidapi.Helpers;
procedure SendBroadcast(const AIntent: JIntent);
var
LResolveInfoList: JList;
LResolveInfo: JResolveInfo;
LComponentName: JComponentName;
LExplicitIntent: JIntent;
I: Integer;
begin
if TJBuild_VERSION.JavaClass.SDK_INT >= 26 then
begin
LResolveInfoList := TAndroidHelper.Context.getPackageManager.queryBroadcastReceivers(AIntent, 0);
for I := 0 to LResolveInfoList.size - 1 do
begin
LResolveInfo := TJResolveInfo.Wrap(TAndroidHelper.JObjectToID(LResolveInfoList.get(I)));
LComponentName := TJComponentName.JavaClass.init(LResolveInfo.activityInfo.applicationInfo.packageName, LResolveInfo.activityInfo.name);
LExplicitIntent := TJIntent.JavaClass.init(AIntent);
LExplicitIntent.setComponent(LComponentName);
TAndroidHelper.Context.sendBroadcast(LExplicitIntent);
end;
end
else
TAndroidHelper.Context.sendBroadcast(AIntent);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment