我必须编写一个简单的应用程序来读取 ISO B 卡
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tag_viewer);
mTagContent = (LinearLayout) findViewById(R.id.list);
mTitle = (TextView) findViewById(R.id.title);
resolveIntent(getIntent());
}
void resolveIntent(Intent intent) {
// Parse the intent
String action = intent.getAction();
Log.e(TAG, "toto ");
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
try{
myTag.connect();
if (myTag.isConnected()){
byte[] response = myTag.transceive(command);
//logText(new String(response));
Log.e(TAG, "Result " + response);
}
myTag.close();
}catch (IOException e) {
e.printStackTrace();
}
} else {
Log.e(TAG, "Unknown intent " + intent);
finish();
return;
}
}
我的问题是我没有成功进入测试 if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action))。我系统地有“未知的意图”。
关于清单:
<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.CALL_PHONE" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
>
<activity android:name="TagViewer"
android:theme="@android:style/Theme.NoTitleBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
</activity>
</application>
<uses-sdk android:minSdkVersion="9" />
<uses-feature android:name="android.hardware.nfc" android:required="true" />
谢谢你的帮助。