Invoking HP ePrint Android application

匿名 (未验证) 提交于 2019-12-03 02:52:02

问题:

I am working on an android app that should invoke android HP ePrint application for wireless printing. For that purpose, I'm using code:

Intent intent = new Intent("com.hp.android.print.PRINT"); intent.setPackage("com.hp.android.print");  startActivityForResult(intent, 0);

I am pretty sure that I didn't get intent's action right... Does anybody know what is the right action to invoke this HP ePrint application? And how can I pass the exact file to print (intent.putExtra(...)).

Thanks

回答1:

After more than 10 hours, I managed to find the solution. Right code to invoke HP ePrint application is like this:

      Uri uri = Uri.fromFile( f );     Intent intent = new Intent ("org.androidprinting.intent.action.PRINT");     intent.setDataAndType( uri, "text/plain" );     context.startActivityForResult(intent, 0);  


回答2:

After my android 5.0.1 app has created a JPEG file, I use the following code to start a wireless print operation (via HP ePrint version 3.4):

Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri uri = Uri.fromFile(new File("something.jpg")); intent.setDataAndType(uri, "image/*"); activity.startActivity(intent); 

The code works cleanly, but every time I print something I have to manually set the paper size to 'A4' and paper type to 'plain'. (It defaults to 'photo'.)

I would be very interested in documentation on how to pass Intent parameters to HP ePrint.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!