【发布时间】:2018-08-09 23:00:30
【问题描述】:
我正在构建一个通过 NFC 发送数据的应用。我让它工作但改变了命名空间,一些构建选项来发布 APK,更新 Android Studio 和其他东西,但没有改变代码,它不再工作了。
这是我的清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.devdr.touch"
android:versionCode="1"
android:versionName="0.1" >
[...]
<activity
android:name="com.devdr.touch.ui.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.devdr.touch.ui.NFCDisplayActivity"
android:label="NFC Data Display">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/com.devdr.touch" />
</intent-filter>
</activity>
这是我的 NDEF 消息:
// Record to launch Play Store if app is not installed
NdefRecord appRecord = NdefRecord.createApplicationRecord(this.getPackageName());
// Record with actual data we care about
NdefRecord relayRecord = NdefRecord.createMime(
"application/" + this.getPackageName() ,
byteArray);
// Complete NDEF message with both records
NdefMessage mNdefMessage = new NdefMessage(new NdefRecord[]{relayRecord
, appRecord
});
this.getPackageName() 处的断点给出:“com.devdr.touch”
现在接收数据的手机会启动手机参数或我的应用程序但在 MainActivity如果 AAR 不存在,或我的应用程序但在 MainActivity如果 AAR 存在。
有什么建议可以调试吗?
编辑 1
添加我的清单的一部分和this.getPackageName() 的值。当我开始签署我的 APK 以发布版本时,它或多或少地开始出现错误。
编辑 2
好的,现在我知道问题出在哪里,但不知道如何解决:
变量byteArray 由一个对象组成。该对象包含 2 个字符串和 1 个图像。现在我正在发送更大的图像,这似乎没有得到正确处理。使用 50ko 图像需要 40 秒!知道为什么这么慢吗?
【问题讨论】:
-
你的包名还是“com.devdr.touch”吗?在您创建记录时,
this.getPackageName()的值是多少? -
是的,添加了编辑 1。谢谢
标签: android nfc intentfilter ndef android-applicationrecord