佳能IP100 android蓝牙打印

2019-12-23  本文已影响0人  橘子神明

对着设备绕了一圈,扣扣挖挖,发现没有蓝牙模块。淘宝买了一个BU-30蓝牙模块装上去就可以用了。
开头采用分享的方式,发现图片会歪一边,文档则会乱码。
后面采用printershare来解决。
1.安装一个破解版printershare.apk
2.写个工具类

public void printPdf(Context context,String pdfpath)
{
    File pdf= new File(pdfpath);    
    ComponentName comp = new ComponentName(thridAppPkg,thridAppCls);
    Intent intent = new Intent();
    try {
        if (Build.VERSION.SDK_INT >= 24) {//7.0 Android N
            //com.xxx.xxx.fileprovider为上述manifest中provider所配置相同
            Uri uri = FileProvider.getUriForFile(context, "com.xunfa.kf.safetyapp.provider", pdf);
            intent.setComponent(comp);
            intent.setAction("android.intent.action.VIEW");
            intent.setType("application/pdf");
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            intent.setData(uri);
        } else {
            intent.setComponent(comp);
            intent.setAction("android.intent.action.VIEW");
            intent.setType("application/pdf");
            intent.setData(Uri.fromFile(pdf));
        }
        context.startActivity(intent);
    }catch (Exception e)
    {
        e.printStackTrace();
    }
}

3.调用printPdf方法写入pdf路径打印,第一次需要加载驱动,和加载预览模块。挂VPN的很快久搞定。

上一篇 下一篇

猜你喜欢

热点阅读