Help with developing a beacon service extension

I'm trying to develop a new AI2 extension making use of "Android Beacon Library" but I have problems starting the "beacon service": it doesn't start at all, in fact the callback method "onBeaconServiceConnect" is never invoked.

A possible cause of that is described in a forum where I found the following explanations:

"A failure to receive a callback to onBeaconServiceConnect is usually caused by an incorrect AndroidManifest.xml setup to declare the BeaconService . The library uses manifest merging to automatically merge these definitions into your app's AndroidManifest.xml from the library's AndroidManifest.xml at compile time. If manifest merging is not enabled, the service will never be declared and the app will not get the onBeaconServiceConnect callback."

"Just solved the problem by adding services declaration to manifest...

Adding following helps:




"

How can I manage to get such manifest modification through my Java code and/or some directive to insert in the appinventor environment I'm using for developing custom extensions ?

Thank you

P.S. I can confirm that my extension's Java code is OK because I tested a draft apk containing the extension with an AndroidManifest.xml I MANUALLY modified using "apktool" and the method "onBeaconServiceConnect" is regularly invoked.

It depends on the type of modification required. Features such as broadcast receivers can be added using annotations (e.g., @UsesBroadcastReceiver). Depending on the nature of the manifest modification, it’s possible to specify it using a set of annotations. What modifications did you make with apktool to the app?

1 Like

I just added the following lines in the AndroidManifest.xml:

    <service android:enabled="true" android:exported="true" android:isolatedProcess="false" android:label="beacon" android:name="org.altbeacon.beacon.service.BeaconService">
    </service>
    <service android:enabled="true" android:name="org.altbeacon.beacon.BeaconIntentProcessor">
    </service>

… and everything was running OK !

It would be very useful if we could use one or more annotations of type “@UsesService” in order to insert one or more stanzas defining specific services in AndroidManifest.xml when the extension is added to the application

Unfortunately that’s not supported at the moment, and we likely won’t implement it as extension support for services isn’t on our critical path. If you or someone else wants to implement this and submit a pull request on GitHub we will consider it for inclusion in the production system.

The implementation of a new annotation is beyond the scope of my project. But I want to inform you that my BLE beacon extension is now completed and tested (of course with the apktool workaround described above).
The extension is based on the Altbeacon Android Library and actually it’s able to detect both iBeacons and AltBeacons.
In a future release I will add support for Eddystone beacons too.
An event is triggered when the “closest beacon” appears, changes or disappears.
An other event is triggered when a change arise in the set of beacons detected within the desired distance from the device.
It is possible to pass parameters such the maximum distance for detection and a list of UUIDs for scan filtering.
I will be glad to share this extension when your production system is going to offer extension support for services.
I hope to hear you when this will be available.

Did you finish your beacon service extension to read beacon data on wifi?
Thanks.
Julien

Hello,

I'm very interested by this Ibeacon extension, do you have some news about them ?

Thanks,

1 Like

Hi BenjiApp,
As I stated in my previous posts this extension would require a new "annotation" in order to automatically insert one or more stanzas defining specific services in AndroidManifest.xml when the extension is added to the application, but I'm not interested in such kind of development.
What I can do for you is to give you the java source of my extension "as it is", but you must be aware that once you get the .apk file of an app embedding this extension you need to modify the AndroidManifest.xml by using "apktool" program.
Let me know,
By

Hello,

Thanks a lot, I'm okay to try your extension even If I need to use apktool to modify the manifest.
How I can do to get the extention ?

Thanks for your work !

Hello everyone,

I trying to create an application ables to read data from a beacon without "connecting" to it. It works well for eddystone beacon, i can read the data thanks to the function "ScanAdvertisement" and "AdvertisementData".
But when i try to read from an iBeacon (knowing the deviceAdress and the serviceUuid thanks to nRF Connect), an error occurs, nothing is read.
Have someone already worked on it ?
Thanks in advance :slight_smile:

I developed an extension making use of the Java library "AltBeacon". This extension can detect beacons of type iBeacon and AltBeacon (not Eddystone).
You must consider that those kinds of beacons do not broadcast any data except 4 hex values (UUID, Major, Minor and Tx-Power) which are useful ONLY for indentifying the beacon and evaluating (roughly) its distance from the receiving device.
The extension requires to manipulate the .apk (with apktool) in order
to add some lines in the AndroidManifest.xml.

meanwhile you can add some lines into the manifest in the extension, see the Annotations documentation App Inventor Annotations - Google Docs

Taifun

You are right Taifun, but I'm currently using Kodular where is not yet allowed the "UsesServices" annotation. Meanwhile I could share the Java code of my extension together with the "service" lines to be added in AndroidManifest.xml

Then why not use the Kodular community? :thinking:

Oh great ! Thanks for your work !
How can I get this extension ?

OK flyingPencil.
If you give an email address I will send you the instructions and files as attach.

Dear @Piero_Della_Romanesc
I am also working on iBeacon using MIT app inventor and I realized that BLE Extension can't help me.
Can you share your extension with me, I would like to try it. Thanks.

Hello F pencil I am also very interested in this can you please share more info?

Thanks Sander

Hello Flying Pencil How did you managed to read data from eddystone?
Very curious how you did I search allready weeks for it

Thanks Sander