如何创建和启动 Intent? [英] How can I create and start an Intent?
问题描述
我想知道如何使用它来创建和启动意图:
I was wondering how I can create and start an intent using this:
"qsrtech.posprintdriver/.printservice"
"qsrtech.posprintdriver/.printservice"
我下载了 POS 打印机驱动程序 (ESC) 应用程序(这是我尝试访问的应用程序).
I downloaded the POS Printer Driver (ESC) app (which is the app I am trying to access).
我试过了:
String PrintPage = "qsrtech.posprintdriver/.printservice";
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(ComponentName.unflattenFromString(PrintPage));
intent.addCategory(Intent.CATEGORY_LAUNCHER );
startActivity(intent);
但是,我收到一条错误消息:未找到处理此意图的活动"
However, I get an error saying: "No activity found to handle this intent"
我想知道我是否可以做些什么来访问这个意图?问题是我不确定我是从其他应用访问 Activity 还是后台服务(可能是 Intent 服务?).
I was wondering if there is anything I can do to access this intent? The thing is that I'm not sure if I'm accessing an activity or a background service (probably an intent service?) from a different app.
这是解释有关此意图的更多信息的链接.http://www.qsrtechnologies.com/aboutposdriver.html
Here is the link that explains more about this intent. http://www.qsrtechnologies.com/aboutposdriver.html
推荐答案
你可以试试这个:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra("Data", "Test printer\n\n");
sendIntent.setComponent(new ComponentName("qsrtech.posprintdriver","qsrtech.posprintdriver.printservice"));
startService(sendIntent);
这篇关于如何创建和启动 Intent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!