为什么我的 BroadcastReceiver 没有检测到通过 android beam 发送的传入文件

Why is my BroadcastReceiver not detecting incoming files sent over android beam

这是我的 BroadcastReceiver 清单代码:

 <receiver android:name=".BeamFilter" >
        <intent-filter android:priority="99999" >
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/jpg"/>


        </intent-filter>
    </receiver>

这是光束过滤器 class:

package com.example.test.heavykey;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.text.TextUtils;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;


public class BeamFilter extends BroadcastReceiver {
private File mParentPath;

@Override
public void onReceive(Context context, Intent intent) {
    System.out.println("Incoming Data");

}
}

这里是发送光束的代码(来自单独设备上应用程序的另一个实例)

  Intent i = new Intent(Intent.ACTION_SEND);
  i.setType("image/jpg");
  i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new    File(Environment.getExternalStorageDirectory(), "test.jpg")));
  startActivity(Intent.createChooser(i, "Send image"));

文件已成功保存到外部目录,但我无法弄清楚为什么我的广播接收器没有执行。任何帮助将不胜感激。

android.nfc.action.NDEF_DISCOVERED is an activity action。写一个 Activity,而不是 BroadcastReceiver.