如何从我当前的应用程序在 Android 中打开 PrinterShare 应用程序

发布于 2024-12-04 11:07:49 字数 198 浏览 2 评论 0原文

当我开发 Android 应用程序时,我发现需要启动安装在 Android 手机上的 PrinterShare 应用程序。我希望当用户点击我的应用程序中的 Button 控件时,它应该启动 PrinterShare 应用程序。当用户完成他/她需要打印的文档时,它应该从启动时返回主应用程序。

任何想法,代码片段将不胜感激。 谢谢.. :-)

As I am developing an android app, I came across the need of launching the PrinterShare app installed on my android phone. I want that when user hits the Button control in my app, it should launch the PrinterShare app. When user is done with the document which he/she needs to print, then it should come back to home application, from when it was launched.

Any idea, code snippet would be appreciated.
Thanks.. :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小红帽 2024-12-11 11:07:49

最近但幸运的是我得到了答案。
在这里:

Intent i = new Intent(Intent.ACTION_VIEW);
i.setPackage("com.dynamixsoftware.printershare");
i.setDataAndType(printFileUri,"text/plain");
startActivity(i);

其中“printFileUri”如下:

static final Uri printFileUri = Uri.parse("file:///sdcard/Calci_print.txt");

如果有人还有其他建议,最受欢迎..:-)

Lately but fortunately I got the answer.
Here it is:

Intent i = new Intent(Intent.ACTION_VIEW);
i.setPackage("com.dynamixsoftware.printershare");
i.setDataAndType(printFileUri,"text/plain");
startActivity(i);

where 'printFileUri' is as follows:

static final Uri printFileUri = Uri.parse("file:///sdcard/Calci_print.txt");

If anyone has still another suggestion, its most welcomed.. :-)

等风来 2024-12-11 11:07:49

如果收到 ActivityNotFoundException,请查看已安装软件包的实际名称(来自 Android 控制台的 pm 命令)。就我而言,我发现从 Amazon App Store 购买的副本的包名称为 com.dynamixsoftware.printershare.amazon

考虑到我的用户可能会从 Google 获取 PrinterShare 应用程序,我实际上会检查包管理器中是否存在以 开头 的第一个包名称 com.dynamixsoftware.printershare

If you receive an ActivityNotFoundException, take a look at the actual name of the installed package (pm command from Android console). In my case I found that the copy I bought from the Amazon App Store had a package name of com.dynamixsoftware.printershare.amazon.

Given that my users might obtain the PrinterShare app from Google, I actually check the package manager for the first package name beginning with com.dynamixsoftware.printershare.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文