Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 5 Jahren, 7 Monaten
Letzter Beitrag:
vor 4 Jahren, 11 Monaten
Beteiligte Autoren:
Alexander Predl, Ruben Sanchez Peña, Adriano Boller, Paul Murray, Pragma Tix

[WM17] Android BroadcastReceiver Question

Startbeitrag von Alexander Predl am 06.01.2013 11:03

Hi there,

this is a WM17 android deep "hacking" question.

I need a android service which "listen" to certain BroadcastReceiver events.

a) my app should "know" on startup if its connected to a certain Bluetooth device.
b) any events of "STATE_CHANGED" and ACL_CONNECTED/ACL_DISCONNECTED should be received in the app and of course do something.
c) the app should be running at startup, so a service that registers in AlarmManager or extends Service.

My first big "AHA" was, that is possible to create a WM java Listener, a big step forward, but there is no way to use a service or BroadcastReceiver.

So I decompiled a WM17 apk and saw there is a AndroidManifest.xml which I can change and recompile the .apk.

But then I thought about it, and yes it could work, but no it cannot work, because WM will not compile it, right?

So is there a solution to overcome WM limitations in this case? Maybe add a external class? Will it compile then?



Hi Alex,
if you can't do it in Java (on Android !) How can you do it then at all ?

In other words, I doubt that it is impossible to hook Broadcast Receiver Events.

A link may help. so if time permit, I will have a look.


von Pragma Tix - am 06.01.2013 23:39

It appears that WDM17 has a variety of funtions for determining if there is a Bluetooth connection.

This is from the help:

Returns the current activation status of Bluetooth on the device or asks to be notified when the activation status changes. To enable or disable the Bluetooth on the device, use BTActivate.
Note: The Bluetooth functions are not available in the Android emulator.

IF BTStatus() = btDisabled THEN

Finding out the activation status of Bluetooth

-Result- = BTStatus()
-Result-: Integer constant
Activation status of Bluetooth:

btEnabled The Bluetooth is enabled on the device.
btActivationInProgress The Bluetooth is being enabled on the device.
btDeactivationInProgress The Bluetooth is being disabled on the device.
btDisabled The Bluetooth is disabled on the device.
btError The activation status of Bluetooth has not been retrieved.

What else would you need in your app?



von Paul Murray - am 07.01.2013 04:28

@Pragma Tix: yes it is possible, there is always the solution of 2 apk's, one with the service (developed in eclipse) and one real app written in WM17!

@Paul Murray: yes I know this, even more is possible. List of paired devices aso. but unfortunately no list of connected Bluetooth devices even the IDE-help tells you so! This is wrong in documentation (confirmed by pcsoft!).

I need really more, the app "should" be a real service, when the user kills the app, even stops it with the task manager, the app would restart and do things in background.

Next the service needs to check certain things:

a) on app startup is a Bluetooth device connected and which (not paired!!!)
b) is there a update to a connected Bluetooth device (connect/disconnect), so this will bring up the BroadcastReceiver.
c) calls to a webserver (possible), printing out on a Bluetooth printer (this should be possible too, with java)
d) later NFC receive/send.
e) maybe GPS recording if it's necessary

I'm familiar with all the emulators, I have installed a VirtualBox x86 Android 2.3.7 too, with a Bluetooth device (USB) connected! Mostly I double check with 2-3 real devices.


von Alexander Predl - am 07.01.2013 10:07

import android.app.Activity;
import android.content.Intent;
import java.lang.*;
import android.util.*;
import java.lang.Exception;
import android.util.Log;

//Aplicativo = br.com.ilhasoft.padoautorun
//NomeClasse = br.com.ilhasoft.padoautorun.alarm.PadoRunReceiver
//NomeAcao = br.com.ilhasoft.padoautorun.PadoRunReceiver

public static boolean BroadcastReceiver(String Aplicativo, String NomeClasse, String NomeAcao)
try {

if (Aplicativo == null){
return false;

Intent Apk = getActiviteEnCours().getPackageManager().getLaunchIntentForPackage(Aplicativo);
Apk.setClassName(Aplicativo, NomeClasse);
return true;


catch(Exception e) {
return false;

von Adriano Boller - am 26.08.2013 18:43
Very interesting sample. Thank you!!!!


von Ruben Sanchez Peña - am 27.08.2013 10:08
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.