Android™ Requires Chilkat v11.7.0+
Android™
Get the QR Code Capabilities of the Chilkat Version in Use
See more QR Code Examples
Demonstrates the capabilities operation, which describes what the installed version of Chilkat can do: the range of QR versions, the error-correction levels, the operations, the image formats and the limits. A program can check for a feature here instead of testing for a Chilkat version number. The request can be an empty JSON object.Chilkat Android™ Downloads
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkJsonObject json = new CkJsonObject();
CkFormats fmt = new CkFormats();
CkJsonObject jsonOut = new CkJsonObject();
success = fmt.QrCode("capabilities",json,jsonOut);
if (success == false) {
Log.i(TAG, fmt.lastErrorText());
return;
}
Log.i(TAG, "Chilkat version: " + jsonOut.stringOf("productVersion"));
Log.i(TAG, "symbology: " + jsonOut.stringOf("symbologies[0].id"));
Log.i(TAG, "QR versions: " + String.valueOf(jsonOut.IntOf("symbologies[0].encoding.version.min")) + " to " + String.valueOf(jsonOut.IntOf("symbologies[0].encoding.version.max")));
Log.i(TAG, "structured append, most symbols: " + String.valueOf(jsonOut.IntOf("symbologies[0].structuredAppend.maxSymbols")));
int i;
int n;
n = jsonOut.SizeOfArray("symbologies[0].encoding.errorCorrection");
for (i = 0; i <= n - 1; i++) {
jsonOut.put_I(i);
Log.i(TAG, "error correction: " + jsonOut.stringOf("symbologies[0].encoding.errorCorrection[i]"));
}
// The operations this version implements.
n = jsonOut.SizeOfArray("operations");
for (i = 0; i <= n - 1; i++) {
jsonOut.put_I(i);
if (jsonOut.BoolOf("operations[i].available") == true) {
Log.i(TAG, "operation: " + jsonOut.stringOf("operations[i].name"));
}
}
n = jsonOut.SizeOfArray("imageFormats.output");
for (i = 0; i <= n - 1; i++) {
jsonOut.put_I(i);
Log.i(TAG, "image format: " + jsonOut.stringOf("imageFormats.output[i]"));
}
Log.i(TAG, "default timeout: " + String.valueOf(jsonOut.IntOf("limits.timeoutMs.default")) + " ms");
Log.i(TAG, "default largest image: " + String.valueOf(jsonOut.IntOf("limits.maxPixels.default")) + " pixels");
// Sample output:
// Chilkat version: 11.7.0
// symbology: qr
// QR versions: 1 to 40
// structured append, most symbols: 16
// error correction: auto
// error correction: L
// error correction: M
// error correction: Q
// error correction: H
// operation: generate
// operation: measure
// operation: validate
// operation: capabilities
// image format: png
// image format: svg
// default timeout: 10000 ms
// default largest image: 16777216 pixels
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}