Also, printing the receipt takes a couple of seconds to start. Is there a way to speed that up?
LayoutInflater inflater = LayoutInflater.from(CountActivity.this);
final ViewGroup receiptView = (ViewGroup)inflater.inflate(R.layout.receipt_view, null); receiptView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); receiptView.layout(0, 0, receiptView.getMeasuredWidth(), receiptView.getMeasuredHeight()); new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void... voids) { try { //View view = findViewById(R.id.rightFrame); Printer p = getPrinter(); PrintJob printJob = new ViewPrintJob.Builder().view(receiptView).build(); return new PrintJobsConnector(CountActivity.this).print(p, printJob); } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(String id) { // I need to figure out what if anything goes here if (id == null) { return; } //textId.setText(id); //monitorState(); } }.execute();