如何使用printershare应用程序从我的应用程序中打印pdf文件?

时间:2013-01-17 17:33:03

标签: android

你好朋友,

      I am developing an application which has a pdf file and I want to take printout of that file.I want to use printershare application in my application,but I didnt know how to move to that application from my application.

另一件事是我想检查应用程序是否安装在设备上。

是否可以像(pdf文件作为输入)那样为该应用程序提供输入?

请帮助

提前致谢

1 个答案:

答案 0 :(得分:0)

另一件事是我想检查应用程序是否安装在设备上。

你可以使用try& catch块以确定是否已经安装了任何可以处理格式的应用程序,如果不是,那么您可以指示用户从catch块中的playstore下载应用程序。

是否可以像(pdf文件作为输入)那样为该应用程序提供输入?

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);


try {
    startActivity(intent);
} 
catch (ActivityNotFoundException e) {
    Toast.makeText(OpenPdf.this, 
        "No Application Available to View PDF", 
        Toast.LENGTH_SHORT).show();
}

//将用户指向playstore

 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);