Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Androwish: given Java sample Intent code -> to borg activity ? (for Barcode scanner read)

78 views
Skip to first unread message

Harald Oehlmann

unread,
Apr 5, 2019, 9:54:25 AM4/5/19
to
Dear TCL'lers,

I would appreciate to get help to translate a Java sample using Android
intents to Androwish "borg activity" & friends.

The Android device is a Honeywell EDA50k0 with Android 7.1.1 which has a
2D bar code scanner included. The scanner automatically starts on the
scan button and than returns its data to the application.

Here is the condensed java example:

package com.honeywell.sample.intentapisample;public class MainActivity
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
extends AppCompatActivity {
private static final String ACTION_BARCODE_DATA =
"com.honeywell.sample.action.BARCODE_DATA";
private static final String ACTION_CLAIM_SCANNER =
"com.honeywell.aidc.action.ACTION_CLAIM_SCANNER";
private static final String EXTRA_PROFILE =
"com.honeywell.aidc.extra.EXTRA_PROFILE";
private static final String EXTRA_PROPERTIES =
"com.honeywell.aidc.extra.EXTRA_PROPERTIES";

private BroadcastReceiver barcodeDataReceiver
= new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_BARCODE_DATA.equals(intent.getAction())) {
int version = intent.getIntExtra("version", 0);
if (version >= 1) {
String aimId = intent.getStringExtra("aimId");
# some additional result properties are returned
# this is the bar code data of the scan
# which should be received within TCL
}
}
}
};
@Override
protected void onResume() {
super.onResume();
registerReceiver(barcodeDataReceiver,
new IntentFilter(ACTION_BARCODE_DATA));
claimScanner();
}
private void claimScanner() {
Bundle properties = new Bundle();
properties.putBoolean("DPR_DATA_INTENT", true);
properties.putString("DPR_DATA_INTENT_ACTION",
ACTION_BARCODE_DATA);
sendBroadcast(new Intent(ACTION_CLAIM_SCANNER)
.putExtra(EXTRA_PROFILE, "MyProfile1")
.putExtra(EXTRA_PROPERTIES, properties)
);
# I am not sure if the property stuff is really required.
# Also, to set the profile is not sure to be required.
}
}

I suppose, I first have to claim the scanner once (which is done above
by the "onResume" function).
Then, I would receive a Broadcast when a scan happened.

Is this possible to write within androwish ?

Any idea appreciated.

Thank you all,
Harald

Harald Oehlmann

unread,
Apr 6, 2019, 8:15:46 AM4/6/19
to
Christian has answered as follows by private E-Mail:

look close to the example. Both are broadcasts. Thus it might work like
that:

proc callback {args} {
console show
puts "callback: $args"
}

borg broadcast register com.honeywell.sample.action.BARCODE_DATA callback

set args {
com.honeywell.aidc.extra.EXTRA_PROFILE MyProfile1
}

borg broadcast send com.honeywell.aidc.action.ACTION_CLAIM_SCANNER {}
{} {} $args

There is the issue that the key
"com.honeywell.aidc.extra.EXTRA_PROPERTIES" in the argument is a bundle
(like a tcl dict) and that does not work with the current androwish
vecause only scalars are supported. We hope it will work out like that.
Outherwise, you may build the source, which currently has a half working
TCLJBlend to call Java Methods directly. But that is not sure to work.

Harald Oehlmann

unread,
Apr 8, 2019, 12:13:45 PM4/8/19
to
The case is solved and led to this Wiki page:

https://wiki.tcl-lang.org/page/AndroWish%3A+create+%22borg+broadcast+%2E%2E%2E%22+following+Java+Code?V=0

Thanks to all,
Harald
0 new messages