Post date: Mar 18, 2016 9:06:58 PM
Our application specification required that we transfer a SPICE circuit netlist to the Android device. When we want to download a netlist, we access its URL (we assume its uploaded somewhere) through a QR code using the library ZXing. ZXing ("Zebra Crossing") is an open-source Java library for image processing, specifically developed for barcodes [1]. It is the most popular solution for QR codes on Android.
Adding the following lines to the build Gradle script for the application plugin [2]:
dependencies {
⋮
compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
compile 'com.google.zxing:core:3.2.0'
⋮
}
In the MainActivity we must also add the statements
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
The IntentIntegrator and IntentResult simplify the development of a ZXing Android barcode scanner, like managing the background thread for the camera, reducing the running time. IntentIntegrator is a zxing specific class designed to ease calling their intent.
In the body of MainActivity, a button click calls the application by intent, and we use an asynchronous task (DownloadAsyncTask) to manage the download of the netlist. The download is handled as a File. Thus we're able to go from a netlist prepared on a desktop computer to a QR code to our application.
The downloaded circuits are stored in a "app_gallery" folder in the app's local storage folder. The gallery view then works by listing this folder, and passing this to an custom ListView adapater which for each entry reads the first line of the file, which by SPICE convention is a comment giving the title, and presents this as a clickable textview.
[1] https://github.com/zxing
[2] https://github.com/journeyapps/zxing-android-embedded