实际上,我想在移动设备检测到nfc标签时打开我的应用程序。在这里,我尝试这样做,它也尝试打开,但崩溃了,并抛出未找到的类似mainactivity类的异常。我已经添加了mainactivity的代码来检测nfc标签检测,但是我仍然不知道为什么它会抛出异常。如果我将运行该应用程序,然后在我的手机上显示nfc标签,那么它将正常工作。
我已经找到了很多文章,并尝试了所有文章,但没有任何一篇。可能我可能会错过一些东西。预先感谢
我将此代码添加到AndroidManifest.xml:
<activity android:name=".MainActivity" android:label="@string/nfc">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.nfc.category.DEFAULT" />
</intent-filter>
</activity>
我为此收到的错误消息如下:
未处理的异常:
Java.Lang.RuntimeException:无法实例化活动 ComponentInfo {com.att.fieldapp / com.att.fieldapp.MainActivity}: java.lang.ClassNotFoundException:找不到类 路径上的“ com.att.fieldapp.MainActivity”:DexPathList [[zip文件 “ /data/app/com.att.fieldapp-cJ4pGrFzw2mQlFoFQ90lgg==/base.apk"],nativeLibraryDirectories=[/data/app/com.att.fieldapp-cJ4pGrFzw2mQlFoFQ90lgg==/lib/arm64, /data/app/com.att.fieldapp-cJ4pGrFzw2mQlFoFQ90lgg==/base.apk!/lib/arm64-v8a, / system / lib64,/ system / vendor / lib64]]
我的主要活动代码如下所示
[Activity(Label = "Home", Theme = "@style/AppTheme", LaunchMode =
LaunchMode.SingleTop)]
public class MainActivity : AppCompatActivity, IOnMapReadyCallback
{
private ProgressDialog progressDialog = null;
private const string TAG = "MainActivity";
...........
...........
}