MaxGo Anysend

Anysend has been replaced by the RFID app. Please find new versions and guides here.

There are two different ways to use this app. The “Keyboard” method will write any data through the keyboard buffer to the currently focused text field. This means the RFID reader and scanner can be used in any 3rd party app without any code change. The “Broadcast” method will send RFID and barcode data as a broadcast which has to be received in your app’s code. The second approach will require you to add some code to your app but will give you much more control over the service. This document will guide you through the different methods you can integrate this service into your code.

Usage

To top

Basic usage

In the most basic implementation, you’ll start the service to make sure it’s running and register a broadcast receiver to get the results.

// Broadcast receiver to barcode data (device == 1) or tag uid (device == 2)
private BroadcastReceiver receiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent.getAction().equals("com.handheldgroup.anysend.RESULT") == false) return;

        // The device which sent this data. RFID = 2
        int device = intent.getIntExtra("device", -1);
        
        // Numeric representation of the tag type
        int type = intent.getIntExtra("type", -1);
        
        // String representation of the tag type
        String typeName = intent.getStringExtra("type_name");
        
        // Data as byte array
        byte[] dataArray = intent.getByteArrayExtra("data");
        
        // Data as String
        String dataString = intent.getStringExtra("string");

        Log.i("anysend-result", "Device #" + device + " returned " + dataString + " for type " + typeName);
    }
};

// Register the receiver
registerReceiver(receiver, new IntentFilter("com.handheldgroup.anysend.RESULT"));

// Start the service to make sure it's running
Intent intent = new Intent("com.handheldgroup.anysend.RfidService.START");
intent.setPackage("com.handheldgroup.anysend");

// This extra is optional and let's you set a message to be shown as a toast after startup.
// If set to a empty ("") string, no toast will be shown.
intent.putExtra("startup", "Ready to scan tags"); 

startService(intent);

When exiting your app you can stop the service and should unregister the receiver.

Advanced usage

The basic example will work in most cases but there is one important thing to consider regarding the RFID Reader.
The module will scan for tags at a very short interval. While this means that tags will be detected quickly, it can also mean that the same tag will be scanned twice which will call the receiver more than once.
To prevent this, the reader can be turned on and off from your app. This can be used to only scan if a button is pressed and to stop after a successful read.

The following functions let you control the reader.

public void enableRfid() {
Intent intent = new Intent("com.handheldgroup.anysend.SET_STATE");
intent.putExtra("device", true);
sendBroadcast(intent);
}

public void disableRfid() {
Intent intent = new Intent("com.handheldgroup.anysend.SET_STATE");
intent.putExtra("device", false);
sendBroadcast(intent);
}

To only scan one tag, call disableRfid() at the beginning of your receiver function.

To only scan while a button is pressed you can use the following code in your activity.

private final int TRIGGER = KeyEvent.KEYCODE_F10; // Set to whichever key you want to use

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.getKeyCode() == TRIGGER && event.getRepeatCount() == 0){
enableRfid();
return true;
}
return super.onKeyDown(keyCode, event);
}

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if(event.getKeyCode() == TRIGGER && event.getRepeatCount() == 0){
disableRfid();
return true;
}
return super.onKeyUp(keyCode, event);
}

Release notes

To top

See the release notes for this article here.

Was this article helpful?
No
Copyright © 2023 Handheld Group. All rights reserved.
Images, texts and other material downloaded from the Handheld web pages may not be reproduced in any form, without prior written permission from the Handheld Group.
Algiz® and Nautiz® are registered trademarks of Handheld Group AB. l Privacy Policy l Device Policy l GDPR l Legal