I'd like to print an image from my sd card with a Zebra EM220. I tried to use
GraphicsUtil.printImage("image path", 0, 0)
but all my attempts failed and I'm just able to print a list of characters.
In a first time, I tried to use that :
ZebraPrinter zp = ZebraPrinterFactory.getInstance(printerCo);
zp.getGraphicsUtil().printImage(path, 0, 0);
But the result was a ZebraLanguageUnknownException.
So I followed this solution : https://km.zebra.com/kb/index?page=content&id=SO8239&actp=LIST_RECENT but just a list of characters was printed.
I have no idea how to solve the problem so if someone succeeded to print an image with the Zebra EM 220 and can share the code, it should help me.
My code :
public void print(){
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myimage.jpg";
ZebraPrinterConnection printerCo = new BluetoothPrinterConnection(printerMacAdress);
try {
printerCo.open();
if (printerCo.isConnected()){
ZebraPrinter zp = new ZebraPrinterCpcl(printerCo);
zp.getGraphicsUtil().printImage(path, 0, 0);
Thread.sleep(500);
}
} catch (ZebraPrinterConnectionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
try{
// Close the connection to release resources.
printerCo.close();
} catch (ZebraPrinterConnectionException e) {
e.printStackTrace();
}
}
}
}
Are you using the ZebraLink SDK? If so, it does not support the EM220. The ZebraLink SDK is designed for use with CPCL and ZPL printers. You can see the list of supported printers here: (click the compatible printers link in the middle): http://www.zebra.com/us/en/products-services/software/adapt-software/zebralink-sdk-android.html#mainpartabscontainer_71ac=downloads.
For the EM 220, you should instead use Zebra's EM 220 SDK for Android (bottom link): http://www.zebra.com/us/en/support-downloads/mobile/em-220.html.
And here is a quick piece of sample code (from Zebra's knowledgebase) explaining one method of printing through this SDK to an EM 220: https://km.zebra.com/kb/index?page=answeropen&type=open&searchid=1363808738897&answerid=16777216&iqaction=5&url=https%3A%2F%2Fkm.zebra.com%2Fkb%2Findex%3Fpage%3Dcontent%26id%3DSA316%26actp%3Dsearch%26viewlocale%3Den_US&highlightinfo=4194576,157,181#.
Related
I'm trying to use the SensorDirectChannel added in Andriod 8. With the memory file as shared medium it is all zero. Using the hardware buffer the returned array is of size zero.
I initiate the SensorDirectChannel like this:
if (mSensor.isDirectChannelTypeSupported(SensorDirectChannel.TYPE_HARDWARE_BUFFER)) {
try {
hawBuff = HardwareBuffer.create(1040, 1, HardwareBuffer.BLOB, 1, HardwareBuffer.USAGE_SENSOR_DIRECT_DATA);
mSensorDirectChannelBuff = mSensorManager.createDirectChannel(hawBuff);
mSensorDirectChannelBuff.configure(mSensor, SensorDirectChannel.RATE_FAST);
} catch (Exception e) {
e.printStackTrace();
}
}
Then I try to read from the hardware buffer like this:
if (mSensorDirectChannelBuff.isOpen()) {
Parcel measurement = Parcel.obtain();
hawBuff.writeToParcel(measurement, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
int[] measurementArray = measurement.createIntArray();
try {
Log.d("SensorDirectChannel", "HardwareBuffer: " + measurementArray[0]);
} catch (Exception e) {
Log.e("HardwareBuffer", "array is empty");
e.printStackTrace();
}
}
The array is always of size zero.
I don't know if I missed something in the docs or what I'm doing wrong.
Does someone have an idea what's wrong?
Now, after some software updates, the smartphone does no longer support sensor direct channels. The line mSensor.isDirectChannelTypeSupported(SensorDirectChannel.TYPE_HARDWARE_BUFFER) now returns false. The same is the case for the memory file option.
So I guess it never worked from the start, causing my problems trying to use it.
'DataWedge' services automatically place scan data in an 'inFocus' field like an EditText, However I would like this functionality turned off so I can place the data where I want
I have already tried searching the internet and trawling through the settings. Awaiting response from customer service
here is some code I tried for Datalogic which did not work
var keywedge = KeyboardWedge(mBarcodeManager)
//keywedge.enable = BooleanProperty(0)
keywedge.enable.set(false)
Note. I have solved the Datalogic SDK, I only need help with Honeywell (I missed a step) here is the solution ;)
var keywedge = KeyboardWedge(mBarcodeManager)
keywedge.enable.set(false)
try{
keywedge.store(mBarcodeManager,false)
}catch (e: Exception){
Log.e(TAG, "Cannot disable Wedge", e)
}
I have resolved this one some time ago sorry for the lack of update
Honeywell
//Simply claim the scanner
try{
barcodeReader?.claim()
} catch (e: ScannerUnavailableException){
e.printStackTrace()
}
Datalogic
var keywedge = KeyboardWedge(mBarcodeManager)
keywedge.enable.set(false)
try{
keywedge.store(mBarcodeManager,false)
}catch (e: Exception){
Log.e(TAG, "Cannot disable Wedge", e)
}
Zebra
//Add the Data & Status Listeners then enable
scanner?.addDataListener(this)
scanner?.addStatusListener(this)
scanner?.enable()
after I run any application on my phone, using free version of AIDE -IDE Android, everytime I view LogCat, I get the same message : " run the app to see the log output ".!
Here is the following screenshot :(https://i.stack.imgur.com/uLORU.png)
Is LogCat free on AIDE-IDE Google play app ?
Thank you for your attention.
It's free as far as i know, but you need root access in order for log to work.
Besides: it doesn't work from time to time with root either.
Another option: use following function to log to local file:
public void appendLog(String text)
// https://stackoverflow.com/a/6209739
{
File logFile = new File("sdcard/log.file");
if (!logFile.exists())
{
try
{
logFile.createNewFile();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try
{
//BufferedWriter for performance, true to set append to file flag
BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
buf.append(text);
buf.newLine();
buf.flush();
buf.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Use it like this:
try{
// your code goes here
}catch (Exception e){
appendLog(e.getMessage());
}
You need to add permission for writing_external_storage in Manifest.
There is no problem with your code. However the problem is with AIDE version your using. Am using the Pro and Logcat is working fine for me
I found this way, as shown below, using Log.getStackTraceString(Exception e), to solve my LogCat View trouble on AIDE-IDE Android. The only remaining question is why there is no display of Log.e (TAG,"Exception ",e) ?
Thank you for your attention.
Code of MainActivity (https://i.stack.imgur.com/Dqfc5.png)
I am working on a simple app for the android OS. It needs to reliably communicate with the Arduino Uno. I used the USBSerialDriver with AndroidStudio. I'm getting data but there are dropped characters. my code below. I get the same result when i use apps available on Google Play. Except for one app that does work the Arduino-Communicator. The only thing i guess is that in the Arduino-Communicator they set some setup bytes to the driver to configure the Arduino interface. Is this possible using the libraries i currently use below?
// Get UsbManager
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
// Find the first available driver.
UsbSerialDriver arduinoDrv = UsbSerialProber.acquire(manager);
// setup serial port
if (arduinoDrv != null) {
// establish connection
try {
arduinoDrv.open();
} catch (IOException e) {
e.printStackTrace();
}
try {
arduinoDrv.setBaudRate(9600);
} catch (IOException e) {
e.printStackTrace();
}
try {
numBytesRead = arduinoDrv.read(rxBuff, 500);
} catch (IOException e) {
e.printStackTrace();
}
rxBuff[numBytesRead]=0;
this is the code in the Arduino-Communicator. I just don't know if it will help the drop packet and how to implement it using the USBSerialdriver above.
// Arduino USB serial converter setup
// Set control line state
mUsbConnection.controlTransfer(0x21, 0x22, 0, 0, null, 0, 0);
// Set line encoding.
mUsbConnection.controlTransfer(0x21, 0x20, 0, 0, getLineEncoding(9600), 7, 0);
thanks!
How can one print a pre-made label (made using Zeba Label Designer) that contains variables and set those variables before printing.
I have the following code, but I am not sure how to set a variable (eg. I have a QR Code in the label I designed and I would like to set its data before printing).
TcpPrinterConnection zebraPrinterConnection = new TcpPrinterConnection("192.168.1.100", TcpPrinterConnection.DEFAULT_ZPL_TCP_PORT);
try {
ZebraPrinter printer = ZebraPrinterFactory.getInstance(zebraPrinterConnection);
printer.getFileUtil().sendFileContents("/sdcard/documents/labels/sample.lbl");
zebraPrinterConnection.close();
} catch (ZebraPrinterConnectionException e) {
e.printStackTrace();
} catch (ZebraPrinterLanguageUnknownException e) {
e.printStackTrace();
} catch (ZebraIllegalArgumentException e) {
e.printStackTrace();
}
You need to look at the output from Zebra Label Designer to get your variables and then hook them up through the sdk
Checkout the documentation that came with the ZebraLink SDK, it has a bunch of good examples on how to print stored formats. Here's one of the examples. In this example, the "First Name" variable is number 12. The "Last Name" variable is number 11.
^XA
^DFE:FORMAT.ZPL
^FS
^FT26,243^A0N,56,55^FH\^FN12"First Name"^FS
^FT26,296^A0N,56,55^FH\^FN11"Last Name"^FS
^FT258,73^A0N,39,38^FH\^FDVisitor^FS
^BY2,4^FT403,376^B7N,4,0,2,2,N^FH^FDSerial Number^FS
^FO5,17^GB601,379,8^FS
^XZ
TcpPrinterConnection zebraPrinterConnection = new TcpPrinterConnection("192.168.1.32", TcpPrinterConnection.DEFAULT_ZPL_TCP_PORT);
try {
zebraPrinterConnection.open();
ZebraPrinter printer = ZebraPrinterFactory.getInstance(zebraPrinterConnection);
Map<Integer, String> vars = new HashMap<Integer, String>();
vars.put(12, "John");
vars.put(11, "Smith");
printer.getFormatUtil().printStoredFormat("E:FORMAT.ZPL", vars);
zebraPrinterConnection.close();
} catch (ZebraPrinterConnectionException e) {
e.printStackTrace();
} catch (ZebraPrinterLanguageUnknownException e) {
e.printStackTrace();
}