如何从我的Android应用程序打开当前活动当前应用程序

时间:2015-11-18 07:30:22

标签: android android-intent android-activity uri

我正在开发具有打印无线功能的新应用程序。我正在使用ePrint技术。我以前生成的PDF文件,我想直接使用ePrint应用程序(apk)预览它,如下图所示: enter image description here

我有我的pdf文件的URI,然后我已经反编译了ePrint应用程序(apk),并在其清单中找到了这个。我不确定,但我认为下面的屏幕截图是指预览活动。

enter image description here

那么如何从我的应用程序直接打开ePrint预览活动,并且我有要打印的参数URI文件?

提前谢谢。

1 个答案:

答案 0 :(得分:0)

试试这个: 以下代码可能会解决您的问题。

仅当您的库中有ACTION_PRINT时才会起作用。

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/pdf_name.pdf");
Intent intent = new Intent();
intent.setAction("org.androidprinting.intent.ACTION_PRINT");
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);