相机意图后 NFC 停止在设备上工作

NFC stops working on Device after Camera Intent

我正在开发一款可以拍照和扫描 NFC 标签的应用程序。 NFC 标签扫描工作正常,直到我拍照(通过相机意图)。

我的工作:

在 onResume() 中调用 setupForegroundDispatch(),在 onPause() 中调用 stopForegroundDispatch()。

public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) {
    final Intent intent = new Intent(activity, activity.getClass());
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    final PendingIntent pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0);
    adapter.enableForegroundDispatch(activity, pendingIntent, null, null);
}

public static void stopForegroundDispatch(final Activity activity, NfcAdapter adapter) {
    adapter.disableForegroundDispatch(activity);
}

启动摄像头我调用:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
                imageCaptureUri);
intent.putExtra("return-data", true);
startActivityForResult(intent, PICK_FROM_CAMERA);

总结一下:

我试过的

我想你可能 运行 喜欢这个

也许你应该尝试使用不同的设备,如果你有的话