2***@qq.com
2***@qq.com
  • 发布:2020-07-28 16:07
  • 更新:2022-09-15 18:07
  • 阅读:2406

uniapp 在真机运行标准基座和自定义基座一个正常一个不起作用

分类:uni-app

uniapp 在真机运行标准基座时nfc可以读取到uid也可以用uni.chooseImage()选择照片,但是用自定义基座nfc读取没反应,用uni.chooseImage()选择照片app闪退,有知道的吗

2020-07-28 16:07 负责人:DCloud_Android_zl 分享
已邀请:
DCloud_App_Array

DCloud_App_Array

Android还是iOS?请详细描述复现问题环境。
调用什么API操作NFC?
自定义基座是如何生成的?是否包含操作NFC的权限?是否允许访问相册权限?

  • 2***@qq.com (作者)

    Android 系统 NFC 跟 相册的权限都有

    try {

    var main = plus.android.runtimeMainActivity();

    //console.log(main);

    var Intent = plus.android.importClass('android.content.Intent');

    // console.log(Intent);

    var Activity = plus.android.importClass('android.app.Activity');

    //console.log(Activity);

    var PendingIntent = plus.android.importClass('android.app.PendingIntent');

    // console.log(PendingIntent);

    var IntentFilter = plus.android.importClass('android.content.IntentFilter');

    // console.log(IntentFilter);

    // var Uri = plus.android.importClass('android.net.Uri');

    // var Bundle = plus.android.importClass('android.os.Bundle');

    // var Handler = plus.android.importClass('android.os.Handler');

    //console.log(Handler);

    NfcAdapter = plus.android.importClass('android.nfc.NfcAdapter');

    console.log(NfcAdapter);

    var _nfcAdapter = NfcAdapter.getDefaultAdapter(main)

    // console.log(_nfcAdapter);


                    var ndef = new IntentFilter("android.nfc.action.NDEF_DISCOVERED"); //NfcAdapter.ACTION_NDEF_DISCOVERED    
    // console.log(ndef);
    var tag = new IntentFilter("android.nfc.action.TAG_DISCOVERED"); //NfcAdapter.ACTION_TECH_DISCOVERED
    // console.log(tag);
    var tech = new IntentFilter("android.nfc.action.TECH_DISCOVERED");
    // console.log(tech);
    var intentFiltersArray = [ndef, tag, tech];

    var techListsArray = [
    ["android.nfc.tech.Ndef"],
    ["android.nfc.tech.IsoDep"],
    ["android.nfc.tech.NfcA"],
    ["android.nfc.tech.NfcB"],
    ["android.nfc.tech.NfcF"],
    ["android.nfc.tech.Nfcf"],
    ["android.nfc.tech.NfcV"],
    ["android.nfc.tech.NdefFormatable"],
    ["android.nfc.tech.MifareClassi"],
    ["android.nfc.tech.MifareUltralight"]
    ];

    var _intent = new Intent(main, main.getClass());
    // console.log(_intent);
    _intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    var pendingIntent = PendingIntent.getActivity(main, 0, _intent, 0);
    // console.log(pendingIntent);

    if (_nfcAdapter == null) {
    this.tip = '本设备不支持NFC!';
    } else if (_nfcAdapter.isEnabled() == false) {
    this.tip = 'NFC功能未打开!';
    } else {
    this.tip = 'NFC正常';
    _nfcAdapter.enableForegroundDispatch(main, pendingIntent, IntentFilter, techListsArray);
    }
    } catch (e) {
    //TODO handle the exception
    }

    用这个调用的NFC 在页面onshow的时候调用这个方法 这时在 用uni.chooseImage() 选择照片点完成时闪退

    用云打包生成的自定义调试基座和正式打包都会闪退 用标准运行基座就没问题

    2020-07-29 10:44

  • DCloud_Android_zl

    回复 2***@qq.com: 提供一个app,我们这边复现一下。

    2020-07-29 11:26

  • 2***@qq.com (作者)

    回复 DCloud_Android_zl: 在那提交模板呢

    2020-07-29 17:31

  • 2***@qq.com (作者)

    还没正式发布

    2020-07-29 17:43

  • DCloud_Android_zl

    回复 2***@qq.com: 可以上传到百度网盘

    2020-07-29 17:45

DCloud_App_Array

DCloud_App_Array

应该是漏设置某个权限引起的。

s***@163.com

s***@163.com - General

我这边也遇到类似问题,请问解决了吗?

s***@126.com

s***@126.com

我也遇到了同样的问题,
因为加了原生 rfid 识别插件,打了自定义的测试基座。
nfc 无法识别,uni.uni.chooseImage() 退出时闪退
请问问题解决了吗

2***@qq.com

2***@qq.com

nfc 添加:"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>"

2***@qq.com

2***@qq.com

问题解决了吗?运行基本基座就没问题,运行自定义基座就会遇到nfc读取没有反应

要回复问题请先登录注册