C API Samples: Difference between revisions

From wizarPOS
No edit summary
No edit summary
Line 1: Line 1:
== JNI Samples ==
== JNI Samples ==
In order to use the device JNI interface, please download the [ftp://sdkuser:wizsdkar@ftp.wizarpos.com/APIDemo_as_jniintf.zip API demo]
In order to use the device [http://{{SERVERNAME}}:9292/jniinterfaceapi/ JNI interface], we provide some samples, please download them:
=== Printer ===
{| class="wikitable"
Please find the printer JNI Interface from [http://{{SERVERNAME}}:9292/jniinterfaceapi/ API Spec].
|-
 
! Describtion !! Downloads
The calling sequence is open>query_status>begin>write>end>close. Please notice that:
|-
* write method is used for printing content.
| Includes all the devices api demo of the POS || [ftp://sdkuser:wizsdkar@ftp.wizarpos.com/APIDemo_as_jniintf.zip API demo]
* print content should be between begin method and end method.
|-
* query_status should be between open method and close method, but should not be between begin method and end method
| A simple demo to simulate payment, includes msr swipe, pinpad input, printing || [ftp://sdkuser:wizsdkar@ftp.wizarpos.com/SimplePaySimulateDemo.zip SimplePaySimulateDemo]
 
|}
The following code shows how to print some content:
  <syntaxhighlight lang="java">
  int result = PrinterInterface.open();
  if (result <0){
    return;
  }
  Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(),
                R.drawable.printer_barcode_low);
  byte[] arryBeginText = null;
  byte[] arryEndText = null;
  try {
    arryBeginText = mContext.getResources().getString(R.string.print_QR_code).getBytes("GB2312");
    arryEndText = "This is a Bitmap of Barcode".getBytes("GB2312");
  } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
  }
  int result = PrinterInterface.begin();
  if (result <0){
    return;
  }
  result = PrinterInterface.write(arryBeginText, arryBeginText.length);
  if (result <0){
    return;
  }
  // print line break
  writeLineBreak(2);     
  PrinterBitmapUtil.printBitmap(bitmap, 0, 0, true);
  // print line break
  writeLineBreak(2);
  // print text
  write(arryEndText);
  // print line break
  writeLineBreak(2);
  result = PrinterInterface.end();
  if (result <0){
    return;
  }
PrinterInterface.close();
</syntaxhighlight>
=== Contactless card reader ===
Please find the contactless card reader JNI Interface from [http://{{SERVERNAME}}:9292/jniinterfaceapi/ API Spec].
 
=== Smart card reader ===
Please find the smart card reader JNI Interface from [http://{{SERVERNAME}}:9292/jniinterfaceapi/ API Spec].

Revision as of 06:58, 20 April 2018

JNI Samples

In order to use the device JNI interface, we provide some samples, please download them:

Describtion Downloads
Includes all the devices api demo of the POS API demo
A simple demo to simulate payment, includes msr swipe, pinpad input, printing SimplePaySimulateDemo