你好朋友,
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文件作为输入)那样为该应用程序提供输入?
请帮助
提前致谢
答案 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);