Android NFC HCE HostApduService 的配置通过 apduservice.xml 实现,其中包含:
<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/servicedesc"
android:requireDeviceUnlock="true" >
<aid-group
android:category="other"
android:description="@string/aiddescription" >
<aid-filter android:name="F0010203040506" />
</aid-group>
</host-apdu-service>
我希望能够在运行时将requireDeviceUnlock设置为用户可配置。我怀疑我可以通过重新启动服务来强制重新加载XML文件:
stopService(new Intent(this, MyHostApduService.class));
startService(new Intent(this, MyHostApduService.class));
但是我如何在运行时更改XML文件中的设置?