B4A Library BroadcastReceiver

viljemto

Member
Licensed User
Longtime User
What would be the difference, if you would have broadcast receiver app made in B4A? In different app, I have in B4A a service with Notification running and it gets killed.

Little broadcast receiver in Eclipse... I have just intent-filter (just like in the link) and it autostart all by itself.

I think it would not get killed, because it is intent-filter and dialer triggers it.
 

viljemto

Member
Licensed User
Longtime User
Hi,

I have tried make a library in Eclipse. Test library works great, but when I want to include lib that uses extends BroadcastReceiver, I get this error.

Maybe has some idea?





Thanks, with regards.
 

warwound

Expert
Licensed User
Longtime User
Looks like you need to add the @Hide annotation to one or more public methods in your java class.

I've seen a similar error when a public library method conflicts with the B4A IDE.

Has your OutgoingCallInterceptor implemented an AbortBroadcast method?
If so add @Hide to that method - just before or after the @override annotation.
If you still get problems you might need to add @Hide to other public methods.

Using @Hide prevents that method from being included in the library XML file - if the XML documents a method that already exists within the IDE you get the parse error.
Use @Hide and the error should go away.

Martin.
 

viljemto

Member
Licensed User
Longtime User
Hi,

thank you for helping. You have pointed me in the wright direction.

No, I do not have AbortBroadcast method. I guess it get it from extends.

Unfortunate @Hide did not work. But I have removed AbortBroadcast manually from xml file and then it loaded OK.

But in following code in Eclipse did not work or did not get executed. Got to figure that out. Thanks!
 

viljemto

Member
Licensed User
Longtime User
Hi guys, maybe this information will be useful to somebody.

I have change order of two apps (mentioned before) for intercept outgoing calls and I can say it works great.

1. app in B4A for dynamic BroadcastReceiver for NEW_OUTGOING_CALL: intercept the call and if needed changes to correct number and calls new number.

2. app in Eclipse for canceling the for call/number
if number is changed let the BroadcastReceiver in 2. app cancel the call.

I was surprised how great it works. If somebody is interested, I can upload the code.

With regards, ViljemT
 

walterf25

Expert
Licensed User
Longtime User
Broadcast Receiver

Hello All, i'm trying to intercept an outgoing SMS message, but i get this error everytime!

hope someone here can tell me what i'm doing wrong!



this is the code

B4X:
Broadcast.Initialize("Broadcastreceiver")
Broadcast.addAction("android.provider.Telephony.NEW_OUTGOING_SMS")
Broadcast.addAction(Broadcast.SMS_RECEIVED)
Broadcast.SetPriority(2147483647)
Broadcast.registerReceiver("")

' Broadcastreceiver sub
Sub Broadcastreceiver_OnReceive (Action As String) 
    ToastMessageShow(Action,False)
   Log(Action)
    'can only abort when sendOrderedbroadcast is called.
    Broadcast.AbortBroadcast
End Sub

the only difference here from the example provided is this line
android.provider.Telephony.NEW_OUTGOING_SMS

other than that i don't see what i get this error./

thanks everyone
Happy Holidays!
 
Last edited:

walterf25

Expert
Licensed User
Longtime User
Broadcast Receiver

Yeah definately there's something wrong with this library, i tried the example that comes with the library and i receive the same error!

java.lang.Exception: Sub broadcastreceiver_onreceive signature does not match expected signature.

hope it can be fixed soon!
 

walterf25

Expert
Licensed User
Longtime User
Broadcast

Never mind i got it, no wonder i received a notification that someone tried accessing my account from somewhere in Slovenia.
My mistake, wow!.
 

Shay

Well-Known Member
Licensed User
Longtime User
WOW well done !!!
I will start to test it / use it, cn solve me lot's of issues...
:sign0188:
 

Shay

Well-Known Member
Licensed User
Longtime User
how do I adjust the sample code
to log all the intent that are running in the phone
It seems that I cannot catch anything, so I wish to see everything is running
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Yeah definately there's something wrong with this library, i tried the example that comes with the library and i receive the same error!



hope it can be fixed soon!

I'm getting the same error, and Broadcast Receiver doesn't show in the list of types when you type sub and press tab


Found it, the new signature is:

Sub BroadcastReceiver_OnReceive (Action As String, i As Object)
Dim i2 As Intent = i
Log(i2.ExtrasToString)
End Sub
 
Last edited:

pappicio

Active Member
Licensed User
Longtime User
hi all.... how to intercept ringermode changed, like this java code:
B4X:
receiver=new BroadcastReceiver(){
        @Override
        public void onReceive(Context context, Intent intent) {
             Log.d("zil", "degisti");

        }
    };
    IntentFilter filter=new IntentFilter(
                    AudioManager.RINGER_MODE_CHANGED_ACTION);
    registerReceiver(receiver,filter);

thanks!
 

RichardBernard

Member
Licensed User
Longtime User
Action_discovery_finished

Hi guys,

I'm trying to get the ACTION_DISCOVERY_FINISHED but it's not working. Can you please tell me what I'm doing wrong?

B4X:
Sub Process_Globals
   Dim Broadcast As BroadCastReceiver
End Sub
Sub Service_Create
   Broadcast.Initialize("BroadcastReceiver")
End Sub

Sub Service_Start(StartingIntent As Intent)
   Broadcast.addAction("android.bluetooth.BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE ")
    Broadcast.SetPriority(999)
    Broadcast.registerReceiver("")
   ToastMessageShow("DiscoveryService Started...",False)
End Sub

Sub Service_Destroy

End Sub

Sub BroadcastReceiver_OnReceive(Action As String)
    ToastMessageShow(Action,False)
    'can only abort when sendOrderedbroadcast is called.
    Broadcast.AbortBroadcast
End Sub

I get my "DiscoveryService Started..." message but no Action is received.

Thanks,
R
 

RichardBernard

Member
Licensed User
Longtime User
Why don't you use BluetoothAdmin object from the Serial library? It already handles this intent.

Do you mean the Admin_DiscoveryFinished event? That only works when search for available devices is done. I'm looking for something that gives an indication after the 300 seconds (or whatever) of being in "discoverable" mode, whether or not a link has been established.

Any ideas?

R
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…