创建设备所有者Android Lollipop时出现校验和错误

时间:2015-01-22 10:40:32

标签: android nfc android-5.0-lollipop

我正在开发设备onwer应用程序,我必须使用NFC安装我的应用程序作为设备所有者但是当我触摸两个设备并尝试安装应用程序时出现错误"无法安装管理员应用程序由于校验和错误"

请告诉我我在哪里做错了。

这是我的代码:

@Override
public NdefMessage createNdefMessage(NfcEvent event) {
    try {
        Properties p = new Properties();

        p.setProperty(
                DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME,
                "com.marakana.android.devicepolicydemo");
        p.setProperty(
                DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION,
                "https://www.dropbox.com/s/0mpolgzm0nufnd6/abc.apk?dl=0");
        p.setProperty(
                DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM,
         //       "3E:3F:9A:A9:29:85:52:61:5E:71:04:2F:CC:D0:B0:CC:A0:29:82:4C");
        "4tEyGrxvIf9XBgGHxneg62a6hAQ");

        p.setProperty(DevicePolicyManager.EXTRA_PROVISIONING_WIFI_SSID, "aaa");
        p.setProperty(DevicePolicyManager.EXTRA_PROVISIONING_WIFI_PASSWORD, "xxxxx");


        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        OutputStream out = new ObjectOutputStream(bos);
        p.store(out, "");
        final byte[] bytes = bos.toByteArray();

        NdefMessage msg = new NdefMessage(NdefRecord.createMime(
                DevicePolicyManager.MIME_TYPE_PROVISIONING_NFC, bytes));
        return msg;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

1 个答案:

答案 0 :(得分:3)

尝试在您的保管箱网址中用dl = 1替换dl = 0:)