Skip to content

Commit

Permalink
Fix to cater for D11.3 and SDK < 31
Browse files Browse the repository at this point in the history
  • Loading branch information
DelphiWorlds committed Jul 16, 2024
1 parent 399b554 commit 0ec5792
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Features/NFC/DW.NFC.Android.pas
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ function JavaBytesToHexString(const ABytes: TJavaArray<Byte>): string;
{ TPlatformNFCReader }

constructor TPlatformNFCReader.Create(const ANFCReader: TNFCReader);
const
FLAG_MUTABLE = $2000000; // https://developer.android.com/reference/android/app/PendingIntent#FLAG_MUTABLE
var
LIntent: JIntent;
LFlags: Integer;
begin
inherited;
TMessageManager.DefaultManager.SubscribeToMessage(TMessageReceivedNotification, MessageReceivedNotificationHandler);
Expand All @@ -103,7 +106,11 @@ constructor TPlatformNFCReader.Create(const ANFCReader: TNFCReader);
MainActivity.registerIntentAction(TJNfcAdapter.JavaClass.ACTION_TECH_DISCOVERED);
MainActivity.registerIntentAction(TJNfcAdapter.JavaClass.ACTION_TAG_DISCOVERED);
LIntent := TJIntent.JavaClass.init(TAndroidHelper.Context, TAndroidHelper.Activity.getClass).addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_SINGLE_TOP);
FPendingIntent := TJPendingIntent.JavaClass.getActivity(TAndroidHelper.Context, 0, LIntent, TJPendingIntent.JavaClass.FLAG_MUTABLE);
if TJBuild_VERSION.JavaClass.SDK_INT >= 31 then
LFlags := FLAG_MUTABLE
else
LFlags := 0;
FPendingIntent := TJPendingIntent.JavaClass.getActivity(TAndroidHelper.Context, 0, LIntent, LFlags);
end;

destructor TPlatformNFCReader.Destroy;
Expand Down

0 comments on commit 0ec5792

Please sign in to comment.