这是indexloc提供的服务,不要输入任何密码
Skip to content

Commit 5040a66

Browse files
Fixed(NfcAPI): Explicitly specify PendingIntent.FLAG_MUTABLE flag for PendingIntent passed to NfcAdapter.enableForegroundDispatch()
- https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability
1 parent 4ba140d commit 5040a66

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/src/main/java/com/termux/api/apis/NfcAPI.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import androidx.annotation.Nullable;
1717
import androidx.appcompat.app.AppCompatActivity;
1818

19+
import com.termux.api.util.PendingIntentUtils;
1920
import com.termux.api.util.ResultReturner;
2021
import com.termux.shared.logger.Logger;
2122

@@ -104,8 +105,11 @@ protected void onResume() {
104105
finish();
105106
return;
106107
}
108+
109+
// - https://developer.android.com/develop/connectivity/nfc/advanced-nfc#foreground-dispatch
107110
Intent intentNew = new Intent(this, NfcActivity.class).addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
108-
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intentNew, 0);
111+
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intentNew,
112+
PendingIntentUtils.getPendingIntentMutableFlag());
109113
IntentFilter[] intentFilter = new IntentFilter[]{
110114
new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED),
111115
new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED),

0 commit comments

Comments
 (0)