私は実際にそれについて10または20のトピックを読んでいて、残念ながらそれを動作させませんでした。私の受信機は、私のアプリからsendBroadcast(intent)
経由で送信する場合にのみ、放送をキャプチャすることができます。 NFCアダプタからのブロードキャストをキャプチャしたい。誰かがNFCタグを自分のデバイスの近くに置いて、私のアプリがブラウジングメニューに表示されたり表示されたりすることはありませんが、それは起こりません。私のアプリが起動し、NFC Tagをデバイスの近くに置いても、それをキャプチャすることはできず、ブラウジングメニューでは他のアプリも見ることができます。 私の受信機:NFCブロードキャストの問題
public class SomeBroadcastReceiver extends BroadcastReceiver {
private final String TAG = "SomeBroadcastReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Got intent: " + intent);
}
}
そして、私のマニフェストファイル:私、
Intent exampleIntent = new Intent("android.nfc.action.NDEF_DISCOVERED"); sendBroadcast(exampleIntent);
アプリはそれらをreches:FakeActivityで
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.nfc">
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name">
<receiver android:enabled="true" android:name=".broadcast.SomeBroadcastReceiver">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/technologies"/>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
</intent-filter>
</receiver>
<activity android:name=".simulator.FakeTagsActivity"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="TagViewer"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="10" />
<uses-feature android:name="android.hardware.nfc" android:required="true" />
私はこのラインを持っています受信機は意図をキャプチャするので、私は薄くするkそのレシーバーは大丈夫ですが、多分私はマニフェストで何かが恋しいですか?グローバル放送をキャプチャする特別な許可はありますか?または私はサービスやsthを開始する必要がありますか?
この問題の解決策をお探しですか? – Antonio