棉花糖及更高版本后,通过意图进行的hp eprint无法正常工作

时间:2018-07-18 13:56:04

标签: android android-intent

在棉花糖下面:

File file = new File(DEST_JOB_CARD_DETAIL);
            file.getAbsolutePath();
            data_uri = Uri.fromFile(file);
Intent intent = new Intent ("org.androidprinting.intent.action.PRINT");
    intent.addCategory (Intent.CATEGORY_DEFAULT);
    intent.setDataAndType (data_uri, "application/pdf");
    startActivityForResult(intent, 1);

牛轧糖及更高版本:

File filedir = new File(DEST_JOB_CARD_DETAIL);
data_uri = FileProvider.getUriForFile(MainActivity.this,getApplicationContext().getPackageName() , filedir);
Intent intent = new Intent ("org.androidprinting.intent.action.PRINT");
    intent.addCategory (Intent.CATEGORY_DEFAULT);
    intent.setDataAndType (data_uri, "application/pdf");
    startActivityForResult(intent, 1);

但是此代码不起作用,有什么办法可以传递hp eprint的意图

0 个答案:

没有答案