你好我有一个POS应用程序(销售点) 我想让它通过蓝牙打印机发送打印数据 我找到了这个解决方案 https://play.google.com/store/apps/details?id=com.fidelier.posprinterdriver 它是我的打印机的驱动程序 他们说
+### Print from your Android App (interactive user action)
+
+Create your ESC data using the helpers Create an Android Intent using Add your ESC data as a “Data” extra Start the intent.
+You can be printing in minutes with just a couple lines of code. It's as simple as creating your intent, adding your ESC formatted string and start the (service) intent.
+
+Example:
+
+```java
+
+String dataToPrint="$big$This is a printer test$intro$posprinterdriver.com$intro$$intro$$cut$$intro$";
+
+Intent intentPrint = new Intent();
+
+intentPrint.setAction(Intent.ACTION_SEND);
+intentPrint.putExtra(Intent.EXTRA_TEXT, dataToPrint);
+intentPrint.setType("text/plain");
+
+this.startActivity(intentPrint);
+
+```
任何人都可以告诉我该怎么办? 我应该把这些代码放在哪里? ?
答案 0 :(得分:0)
假设您的活动中包含指向此方法的按钮链接:
public void click(View v){
Intent intentPrint = new Intent();
intentPrint.setAction(Intent.ACTION_SEND);
intentPrint.putExtra(Intent.EXTRA_TEXT, "Just some dummy text to print");
intentPrint.setType("text/plain");
this.startActivity(intentPrint);
}
通过单击此按钮,将启动意图,这可能会打开一个可以处理此类意图的应用程序列表(ACTION_SEND),选择正确的意图,这应该这样做。